test: merge PR #13 test coverage improvements into main

Resolves merge conflicts between Phase 4.2 comprehensive test suite and
the test coverage improvement branch:
- config_test.go: take PR's better table-driven tests + keep main's extra tests
- coverage_test.go: keep main's Phase 4.2 comprehensive tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
Gary Hansen
2026-06-08 04:24:56 +10:00
co-authored by Copilot multica-agent
4 changed files with 1532 additions and 39 deletions
+60 -39
View File
@@ -216,55 +216,76 @@ func TestParseDebugLevel(t *testing.T) {
}
func TestParseMaxDepthValid(t *testing.T) {
cases := []string{"1", "20", "100"}
for _, s := range cases {
v, err := ParseMaxDepth(s)
if err != nil {
t.Errorf("ParseMaxDepth(%q) unexpected error: %v", s, err)
}
if v < 1 || v > 100 {
t.Errorf("ParseMaxDepth(%q) = %d, out of range", s, v)
}
}
cases := []struct {
input string
want int
}{
{"1", 1},
{"20", 20},
{"100", 100},
}
for _, tc := range cases {
got, err := ParseMaxDepth(tc.input)
if err != nil {
t.Errorf("ParseMaxDepth(%q) unexpected error: %v", tc.input, err)
}
if got != tc.want {
t.Errorf("ParseMaxDepth(%q) = %d, want %d", tc.input, got, tc.want)
}
}
}
func TestParseMaxDepthInvalid(t *testing.T) {
cases := []string{"0", "101", "notanumber"}
for _, s := range cases {
_, err := ParseMaxDepth(s)
if err == nil {
t.Errorf("ParseMaxDepth(%q): expected error", s)
}
if !errors.Is(err, ErrInvalidMaxDepth) {
t.Errorf("ParseMaxDepth(%q): expected ErrInvalidMaxDepth, got %v", s, err)
}
}
cases := []string{"0", "101", "notanumber", "-1"}
for _, s := range cases {
_, err := ParseMaxDepth(s)
if err == nil {
t.Errorf("ParseMaxDepth(%q): expected error", s)
continue
}
if !errors.Is(err, ErrInvalidMaxDepth) {
t.Errorf("ParseMaxDepth(%q): expected ErrInvalidMaxDepth, got %v", s, err)
}
}
}
func TestParseRetriesValid(t *testing.T) {
cases := []string{"0", "5", "10"}
for _, s := range cases {
v, err := ParseRetries(s)
if err != nil {
t.Errorf("ParseRetries(%q) unexpected error: %v", s, err)
}
if v < 0 || v > 10 {
t.Errorf("ParseRetries(%q) = %d, out of range", s, v)
}
}
cases := []struct {
input string
want int
}{
{"0", 0},
{"2", 2},
{"10", 10},
}
for _, tc := range cases {
got, err := ParseRetries(tc.input)
if err != nil {
t.Errorf("ParseRetries(%q) unexpected error: %v", tc.input, err)
}
if got != tc.want {
t.Errorf("ParseRetries(%q) = %d, want %d", tc.input, got, tc.want)
}
}
}
func TestParseRetriesInvalid(t *testing.T) {
cases := []string{"-1", "11", "notanumber"}
for _, s := range cases {
_, err := ParseRetries(s)
if err == nil {
t.Errorf("ParseRetries(%q): expected error", s)
}
if !errors.Is(err, ErrInvalidRetries) {
t.Errorf("ParseRetries(%q): expected ErrInvalidRetries, got %v", s, err)
}
cases := []string{"-1", "11", "notanumber"}
for _, s := range cases {
_, err := ParseRetries(s)
if err == nil {
t.Errorf("ParseRetries(%q): expected error", s)
continue
}
if !errors.Is(err, ErrInvalidRetries) {
t.Errorf("ParseRetries(%q): expected ErrInvalidRetries, got %v", s, err)
}
}
}
func TestPrintUsage(t *testing.T) {
// PrintUsage writes to stderr; just ensure it doesn't panic.
PrintUsage()
}
func TestValidateBadQueryType(t *testing.T) {