Files
login/reference_test.go
T
NeoandClaude bdc84b3ca7 Site: docs/ as d-modem.github.io/menu, with a configuration reference (#8)
docs/reference.md lists every section and key of modemmenu.conf with its
help, the sample's value and the other values the sample shows, read
from the comments of modemmenu.conf.sample by go run ./tools/confref.
TestSampleHasEveryKey fails when the code reads a key the sample doesn't
show: max_input and an item's terminal were missing and are now in it.
The docs index and Configuration link the reference.

mkdocs.yml builds docs/ and the README with brand's shared theme
(Zensical); .github/workflows/pages.yml calls brand's site workflow,
which also fails when docs/reference.md is out of date.


Claude-Session: https://claude.ai/code/session_01B82eRSqjp9Pn2KBr9N9LAn

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-05 17:46:56 -08:00

51 lines
1.2 KiB
Go

// Copyright (C) 2026 D-Modem Authors
// SPDX-License-Identifier: AGPL-3.0-only
package main
import (
"os"
"path/filepath"
"regexp"
"sort"
"strings"
"testing"
)
// TestSampleHasEveryKey: each key the code reads is in
// modemmenu.conf.sample, so it has help there and a line in the
// configuration reference (go run ./tools/confref makes docs/reference.md
// from the sample).
func TestSampleHasEveryKey(t *testing.T) {
sample, err := os.ReadFile("modemmenu.conf.sample")
if err != nil {
t.Fatal(err)
}
inSample := map[string]bool{}
for _, m := range regexp.MustCompile(`(?m)^;?\s*([a-z][a-z0-9_]*)\s*=`).FindAllSubmatch(sample, -1) {
inSample[string(m[1])] = true
}
re := regexp.MustCompile(`\.(?:get|has|bool|int|duration|durations)\("([a-z0-9_]+)"`)
files, _ := filepath.Glob("*.go")
var missing []string
for _, f := range files {
if strings.HasSuffix(f, "_test.go") {
continue
}
src, err := os.ReadFile(f)
if err != nil {
t.Fatal(err)
}
for _, m := range re.FindAllStringSubmatch(string(src), -1) {
if !inSample[m[1]] {
missing = append(missing, f+": "+m[1])
inSample[m[1]] = true
}
}
}
sort.Strings(missing)
for _, m := range missing {
t.Errorf("not in modemmenu.conf.sample: %s", m)
}
}