package main import ( "testing" ) func TestStrVal(t *testing.T) { m := map[string]any{"key": "value"} if got := strVal(m, "key", ""); got != "value" { t.Errorf("strVal(key) = %q", got) } if got := strVal(m, "missing", "def"); got != "def" { t.Errorf("strVal(missing) = %q", got) } } func TestBoolVal(t *testing.T) { m := map[string]any{"flag": true} if got := boolVal(m, "flag", false); !got { t.Error("expected true") } if got := boolVal(m, "missing", false); got { t.Error("expected false fallback") } } func TestGetEnvHelpers(t *testing.T) { t.Setenv("VA_TEST", "hello") if got := getEnv("VA_TEST", "x"); got != "hello" { t.Errorf("getEnv = %q", got) } t.Setenv("VA_PORT", "9090") if got := getEnvInt("VA_PORT", 0); got != 9090 { t.Errorf("getEnvInt = %d", got) } t.Setenv("VA_FLAG", "true") if got := getEnvBool("VA_FLAG", false); !got { t.Error("getEnvBool should be true") } } func TestTruncate(t *testing.T) { if got := truncate("hello world", 5); got != "hello..." { t.Errorf("truncate = %q", got) } if got := truncate("hi", 10); got != "hi" { t.Errorf("truncate short = %q", got) } }