test: improve coverage to >80% on all core packages
CI / test (pull_request) Failing after 2m11s

Add comprehensive test coverage for internal packages:

- internal/config: 66.2% → 98.5%
- internal/dns: 67.8% → 84.3%
- internal/output: 48.8% → 89.1%
- internal/traverse: 56.3% → 86.9%

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 03:57:29 +10:00
co-authored by Copilot multica-agent
parent fe1afe2a97
commit 45e15297f4
5 changed files with 2235 additions and 0 deletions
+73
View File
@@ -214,3 +214,76 @@ func TestParseDebugLevel(t *testing.T) {
}
}
}
func TestParseMaxDepthValid(t *testing.T) {
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", "-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 := []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)
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()
}