mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-09-04 13:36:35 +02:00
pkg: address managed DNS mode review feedback
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user