pkg: address managed DNS mode review feedback

This commit is contained in:
Dev Scribe
2026-08-24 15:18:01 +07:00
committed by Cuong Manh Le
parent 47dd64b901
commit f0b60f3efa
10 changed files with 86 additions and 24 deletions
+27
View File
@@ -36,3 +36,30 @@ func TestUpdateConfigInterceptMode(t *testing.T) {
})
}
}
func TestConfiguredInterceptMode(t *testing.T) {
oldInterceptMode := interceptMode
t.Cleanup(func() { interceptMode = oldInterceptMode })
p := &prog{cfg: &ctrld.Config{}}
p.cfg.Service.InterceptMode = "dns"
tests := []struct {
name string
flag string
want string
}{
{name: "empty flag falls back to config", flag: "", want: "dns"},
{name: "explicit off is final", flag: "off", want: "off"},
{name: "explicit hard wins over config", flag: "hard", want: "hard"},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
interceptMode = tc.flag
if got := p.configuredInterceptMode(); got != tc.want {
t.Fatalf("configuredInterceptMode() = %q, want %q", got, tc.want)
}
})
}
}