feat: comprehensive test suite (Phase 4.2) (#12)
CI / test (push) Failing after 1m30s

This commit was merged in pull request #12.
This commit is contained in:
2026-06-07 17:54:15 +00:00
parent fe1afe2a97
commit e6e07941a5
11 changed files with 2590 additions and 2 deletions
+73
View File
@@ -214,3 +214,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)
}
}
}
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)
}
}
}
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)
}
}
}
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)
}
}
}
func TestValidateBadQueryType(t *testing.T) {
cfg := DefaultConfig()
cfg.QueryType = "BOGUS"
if err := cfg.Validate(); !errors.Is(err, ErrInvalidQueryType) {
t.Errorf("expected ErrInvalidQueryType, got %v", err)
}
}
func TestDefaultConfigIsValid(t *testing.T) {
cfg := DefaultConfig()
if cfg.QueryType != "A" {
t.Errorf("QueryType = %q, want A", cfg.QueryType)
}
if cfg.MaxDepth != 20 {
t.Errorf("MaxDepth = %d, want 20", cfg.MaxDepth)
}
if cfg.Retries != 2 {
t.Errorf("Retries = %d, want 2", cfg.Retries)
}
}