package checks import ( "amadan.net/oficina/equipo/internal/runner/provider" "context" "errors" "slices" "strings" "testing" ) func TestSharedBaselineFixtureIsolation(t *testing.T) { first := newFixture(t) original := slices.Clone(first.d.Baseline.Names) first.d.Baseline.Names[0].Name = "changed" put(t, first.base, "extra_test.go", "package fixture\nimport \"testing\"\nfunc TestExtra(t *testing.T){}\n") second := newFixture(t) if !slices.Equal(second.d.Baseline.Names, original) { t.Fatal("fixtures share mutable baseline names") } fresh, err := second.e.CaptureBaseline(context.Background(), second.d) must(t, err) if fresh.Hash != second.d.Baseline.Hash || !slices.Equal(fresh.Names, original) { t.Fatal("shared baseline differs from fresh isolated capture") } first.d.Baseline.Names = slices.Clone(original) changed, err := first.e.CaptureBaseline(context.Background(), first.d) must(t, err) if changed.Hash == fresh.Hash || !slices.Contains(changed.Names, TestIdentity{Package: "fixture", Name: "TestExtra"}) { t.Fatal("changed fixture bypassed baseline capture") } } func TestCheckFailureDiagnostic(t *testing.T) { f := newFixture(t) _, _, _, err := f.e.run(context.Background(), Command{Argv: []string{"/bin/sh", "-c", "echo namespace-cause >&2; exit 7"}, Dir: ".", Parser: "go-test-json", TimeoutSeconds: 10}, f.base, "") if !errors.Is(err, provider.ErrContract) || !strings.Contains(err.Error(), "namespace-cause") || !strings.Contains(err.Error(), "exit 7") { t.Fatalf("missing check diagnostic: %v", err) } }