fix: complete target diagnostics and reset inspection

This commit is contained in:
proxyctl coordinator
2026-07-17 10:29:41 +08:00
parent f6c6ead325
commit 0fbaa71e37
14 changed files with 366 additions and 10 deletions
+26
View File
@@ -55,6 +55,9 @@ func (r *fakeRunner) Run(_ context.Context, c gnome.Command) (string, error) {
}
return value + "\n", nil
}
if len(c.Args) == 3 && c.Args[0] == "writable" {
return "true\n", nil
}
if len(c.Args) == 4 && c.Args[0] == "set" {
r.values[c.Args[1]+" "+c.Args[2]] = c.Args[3]
return "", nil
@@ -105,6 +108,29 @@ func active() *profile.Profile {
return &profile.Profile{Name: "office", Mode: profile.AdvancedMode, HTTPURL: "http://proxy.example:8080", HTTPSURL: "http://secure.example:8443", AllURL: "socks5://socks.example:1080", Bypass: []string{"localhost", ".example.com", "10.0.0.0/8", "2001:db8::1"}}
}
func TestDiagnosticChecksCoverCommandSchemasSessionAndAuthorityWithoutMutation(t *testing.T) {
r, state := newRunner(), &memoryState{}
a := adapter(r, state)
checks := a.DiagnosticChecks(context.Background(), active())
for _, name := range []string{"required command", "required schemas", "desktop session", "write authority"} {
found := false
for _, check := range checks {
found = found || check.Name == name
}
if !found {
t.Errorf("diagnostics missing %q: %#v", name, checks)
}
}
for _, call := range r.calls {
if len(call.Args) > 0 && call.Args[0] == "set" {
t.Fatalf("diagnostics mutated GNOME settings: %#v", call)
}
}
if state.data != nil {
t.Fatalf("diagnostics wrote GNOME recovery state: %q", state.data)
}
}
func TestGNOMEAdapterRunsReusableTargetContract(t *testing.T) {
targettest.Run(t, func(t *testing.T) targettest.Fixture {
r, state := newRunner(), &memoryState{}