Compare commits

...

1 Commits

Author SHA1 Message Date
fullstack-engineer 5b61ec7350 test(a2a_proxy): add parseIdleTimeoutEnv coverage
parseIdleTimeoutEnv was the only untested pure helper in a2a_proxy.go.
All other helpers (isSystemCaller, isUpstreamBusyError,
isUpstreamDeadStatus, normalizeA2APayload, detectPlatformInDocker)
are already covered in a2a_proxy_test.go. No other files in handlers/
had genuinely untested pure functions after this.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 18:18:18 +00:00
@@ -0,0 +1,59 @@
package handlers
import (
"testing"
"time"
)
// =============================================================================
// parseIdleTimeoutEnv
// =============================================================================
// parseIdleTimeoutEnv is the only untested pure helper in a2a_proxy.go.
// Covered in the full proxy path via idleTimeoutDuration package var, but
// the unit itself had no direct tests until this file.
func TestParseIdleTimeoutEnv_Valid(t *testing.T) {
tests := []struct {
input string
want time.Duration
}{
{"30", 30 * time.Second},
{"60", 60 * time.Second},
{"300", 5 * time.Minute},
{"3600", 1 * time.Hour},
}
for _, tt := range tests {
got := parseIdleTimeoutEnv(tt.input)
if got != tt.want {
t.Errorf("parseIdleTimeoutEnv(%q) = %v; want %v", tt.input, got, tt.want)
}
}
}
func TestParseIdleTimeoutEnv_Empty(t *testing.T) {
got := parseIdleTimeoutEnv("")
if got != defaultIdleTimeoutDuration {
t.Errorf("parseIdleTimeoutEnv(%q) = %v; want defaultIdleTimeoutDuration (%v)", "", got, defaultIdleTimeoutDuration)
}
}
func TestParseIdleTimeoutEnv_InvalidInteger(t *testing.T) {
cases := []string{"abc", "12.5", "1e3"}
for _, v := range cases {
got := parseIdleTimeoutEnv(v)
if got != defaultIdleTimeoutDuration {
t.Errorf("parseIdleTimeoutEnv(%q) = %v; want defaultIdleTimeoutDuration", v, got)
}
}
}
func TestParseIdleTimeoutEnv_NonPositive(t *testing.T) {
cases := []string{"0", "-1", "-30"}
for _, v := range cases {
got := parseIdleTimeoutEnv(v)
if got != defaultIdleTimeoutDuration {
t.Errorf("parseIdleTimeoutEnv(%q) = %v; want defaultIdleTimeoutDuration", v, got)
}
}
}