From d863998d72690ef36c0990d7dbe1e170077859f5 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 10 Aug 2026 11:31:27 -0400 Subject: [PATCH] test: trim dead fixture surfaces --- internal/testfixture/database/store.go | 28 +++----------------- internal/testfixture/sops/executable.go | 4 +-- internal/testfixture/sops/executable_test.go | 10 ------- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/internal/testfixture/database/store.go b/internal/testfixture/database/store.go index b15f0ea..52d8603 100644 --- a/internal/testfixture/database/store.go +++ b/internal/testfixture/database/store.go @@ -27,27 +27,6 @@ func fixtureOrigin() time.Time { return time.Date(2026, 1, 2, 3, 4, 5, 0, time.UTC) } -// Clock is a deterministic clock pinned to a fixed instant. Advance moves the -// instant so tests can produce stable, ordered timestamps. -type Clock struct { - now time.Time -} - -// NewClock returns a Clock pinned at at. -func NewClock(at time.Time) *Clock { - return &Clock{now: at} -} - -// Now returns the pinned instant. -func (clock *Clock) Now() time.Time { - return clock.now -} - -// Advance moves the pinned instant forward by delta. -func (clock *Clock) Advance(delta time.Duration) { - clock.now = clock.now.Add(delta) -} - // Fixture owns one fully isolated state tree. Root is the private container of // the fixture HOME (Home) and the state home (StateHome); Cleanup removes it // wholesale. @@ -55,7 +34,6 @@ type Fixture struct { Root string Home string StateHome string - Clock *Clock Store *state.Store } @@ -71,12 +49,12 @@ func New(t *testing.T) *Fixture { t.Fatalf("fixture home: %v", err) } stateHome := filepath.Join(root, "state") - clock := NewClock(fixtureOrigin()) - store := state.NewStore(state.Dependencies{StateHome: stateHome, Now: clock.Now}) + now := fixtureOrigin() + store := state.NewStore(state.Dependencies{StateHome: stateHome, Now: func() time.Time { return now }}) if err := store.Acquire(context.Background()); err != nil { t.Fatalf("fixture store acquire: %v", err) } - fixture := &Fixture{Root: root, Home: home, StateHome: stateHome, Clock: clock, Store: store} + fixture := &Fixture{Root: root, Home: home, StateHome: stateHome, Store: store} t.Cleanup(func() { _ = fixture.cleanup() }) return fixture } diff --git a/internal/testfixture/sops/executable.go b/internal/testfixture/sops/executable.go index c6ac068..7d8f829 100644 --- a/internal/testfixture/sops/executable.go +++ b/internal/testfixture/sops/executable.go @@ -22,7 +22,6 @@ import ( const ( behaviorSpecEnvironment = "FAKE_SOPS_SPEC" invocationRecordEnvironment = "FAKE_SOPS_RECORD" - fixtureChildEnvironment = "FAKE_SOPS_CHILD" ) // Executable is a handle to the compiled fake binary. @@ -146,7 +145,6 @@ type record struct { Argv []string Cwd string Stdin []byte - Pid int ChildPid int } @@ -161,7 +159,7 @@ func main() { func run() { behavior := loadBehavior() stdin, _ := io.ReadAll(os.Stdin) - invocationRecord := record{Argv: os.Args, Cwd: currentWorkingDirectory(), Stdin: stdin, Pid: os.Getpid()} + invocationRecord := record{Argv: os.Args, Cwd: currentWorkingDirectory(), Stdin: stdin} if behavior.Sleep > 0 { invocationRecord.ChildPid = spawnChild() } diff --git a/internal/testfixture/sops/executable_test.go b/internal/testfixture/sops/executable_test.go index 2e3e894..22b3c35 100644 --- a/internal/testfixture/sops/executable_test.go +++ b/internal/testfixture/sops/executable_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "os" "os/exec" - "path/filepath" "strings" "syscall" "testing" @@ -21,7 +20,6 @@ func TestSOPSExecutableFixture(t *testing.T) { {"large output", testLargeOutput}, {"descendant dies with group", testDescendantDiesWithGroup}, {"cleanup removes the binary", testCleanupRemovesBinary}, - {"record path creation failure", testRecordPathCreationFailure}, } for _, scenario := range scenarios { t.Run(scenario.name, scenario.run) @@ -93,14 +91,6 @@ func testCleanupRemovesBinary(t *testing.T) { } } -func testRecordPathCreationFailure(t *testing.T) { - directory := t.TempDir() - _, err := uniquePath(filepath.Join(directory, "missing"), "record") - if err == nil { - t.Fatal("missing record directory was accepted") - } -} - func waitForChild(t *testing.T, cmd *exec.Cmd) int { t.Helper() path := recordPath(cmd) -- 2.51.2