fix: finish progressive Target detection

This commit is contained in:
proxyctl coordinator
2026-07-17 21:25:43 +08:00
parent ad651402fd
commit 8348fa3ac8
17 changed files with 672 additions and 221 deletions
+15
View File
@@ -46,6 +46,19 @@ func TestAvailabilityRequiresDebianMarkerAPTToolAndConfigurationDirectory(t *tes
}
}
func TestDetectClassifiesInspectionFailureAndUsesOneEffectiveConfigurationProbe(t *testing.T) {
a, runner := newAdapter(t, nil)
runner.outputError = true
detection := a.Detect(context.Background(), compatibleProfile())
if detection.Err == nil || detection.Inspection.State != target.Disabled {
t.Fatalf("detection = %#v, want failed Disabled inspection", detection)
}
if runner.outputs != 1 {
t.Fatalf("Detect issued %d apt-config dumps, want one", runner.outputs)
}
}
func TestDiagnosticChecksCoverCommandSchemaAndAuthorityWithoutMutation(t *testing.T) {
a, _ := newAdapter(t, nil)
checks := a.DiagnosticChecks(context.Background(), compatibleProfile())
@@ -442,6 +455,7 @@ func newFailingAdapter(t *testing.T, files *failingFS) (*apt.Adapter, *fakeRunne
type fakeRunner struct {
available, outputError bool
overlay, external, override, failDumpAfterWrite string
outputs int
}
func (r *fakeRunner) LookPath(string) (string, error) {
@@ -451,6 +465,7 @@ func (r *fakeRunner) LookPath(string) (string, error) {
return "/usr/bin/apt-config", nil
}
func (r *fakeRunner) Output(context.Context, string, ...string) ([]byte, error) {
r.outputs++
if r.outputError {
return nil, errors.New("apt-config dump failed")
}