From 520518c68b03486f07120585b1dfb9356f301370 Mon Sep 17 00:00:00 2001 From: Peter Chanthamynavong Date: Tue, 6 Jan 2026 19:29:57 -0800 Subject: [PATCH] refactor(test): replace testify with stdlib in daemon tests (#936) The daemon socket tests relied on an external assertion library, which increased the module's dependency footprint and deviated from Go's idiomatic testing patterns. This commit introduces a leaner testing approach using the standard library: - Replace testify/assert calls with standard if checks and t.Errorf - Remove testify and associated indirects from go.mod These changes preserve existing test behavior while simplifying the build process and reducing external maintenance overhead. --- cmd/bd/daemon_socket_test.go | 24 +++++++++++++++++------- go.mod | 3 --- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/cmd/bd/daemon_socket_test.go b/cmd/bd/daemon_socket_test.go index 9c4d5678..65a5d00f 100644 --- a/cmd/bd/daemon_socket_test.go +++ b/cmd/bd/daemon_socket_test.go @@ -2,9 +2,8 @@ package main import ( "path/filepath" + "strings" "testing" - - "github.com/stretchr/testify/assert" ) // TestSocketPathEnvOverride verifies that BD_SOCKET env var overrides default socket path. @@ -18,7 +17,9 @@ func TestSocketPathEnvOverride(t *testing.T) { // Verify getSocketPath returns custom path got := getSocketPath() - assert.Equal(t, customSocket, got) + if got != customSocket { + t.Errorf("getSocketPath() = %q, want %q", got, customSocket) + } } // TestSocketPathForPIDEnvOverride verifies that BD_SOCKET env var overrides PID-derived path. @@ -33,7 +34,9 @@ func TestSocketPathForPIDEnvOverride(t *testing.T) { // Verify getSocketPathForPID returns custom path (ignoring pidFile) pidFile := "/some/other/path/daemon.pid" got := getSocketPathForPID(pidFile) - assert.Equal(t, customSocket, got) + if got != customSocket { + t.Errorf("getSocketPathForPID(%q) = %q, want %q", pidFile, got, customSocket) + } } // TestSocketPathDefaultBehavior verifies default behavior when BD_SOCKET is not set. @@ -44,7 +47,10 @@ func TestSocketPathDefaultBehavior(t *testing.T) { // Verify getSocketPathForPID derives from PID file path pidFile := "/path/to/.beads/daemon.pid" got := getSocketPathForPID(pidFile) - assert.Equal(t, "/path/to/.beads/bd.sock", got) + want := "/path/to/.beads/bd.sock" + if got != want { + t.Errorf("getSocketPathForPID(%q) = %q, want %q", pidFile, got, want) + } } // TestDaemonSocketIsolation demonstrates that two test instances can use different sockets. @@ -66,10 +72,14 @@ func TestDaemonSocketIsolation(t *testing.T) { t.Setenv("BD_SOCKET", socketPath) got := getSocketPath() - assert.Equal(t, socketPath, got) + if got != socketPath { + t.Errorf("getSocketPath() = %q, want %q", got, socketPath) + } // Verify paths are unique per instance - assert.Contains(t, got, tt.sockSuffix) + if !strings.Contains(got, tt.sockSuffix) { + t.Errorf("getSocketPath() = %q, want it to contain %q", got, tt.sockSuffix) + } }) } } diff --git a/go.mod b/go.mod index c753b633..85c70343 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( github.com/olebedev/when v1.1.0 github.com/spf13/cobra v1.10.2 github.com/spf13/viper v1.21.0 - github.com/stretchr/testify v1.11.1 github.com/tetratelabs/wazero v1.11.0 golang.org/x/mod v0.31.0 golang.org/x/sys v0.39.0 @@ -37,7 +36,6 @@ require ( github.com/charmbracelet/x/cellbuf v0.0.13 // indirect github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect github.com/charmbracelet/x/term v0.2.1 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect @@ -53,7 +51,6 @@ require ( github.com/ncruces/julianday v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pkg/errors v0.8.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/sagikazarmark/locafero v0.11.0 // indirect github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect