test: use typed atomics in test files (#25071)

Use typed atomics (atomic.Int64, atomic.Int32, etc.) in test files to prevent
mixing atomic and non-atomic access on the same value, guarantee 64-bit
alignment on 32-bit platforms, and provide a cleaner API.
This commit is contained in:
Zach
2026-05-11 08:41:17 -06:00
committed by GitHub
parent a1dbd758bc
commit 81e2be69e9
21 changed files with 115 additions and 116 deletions
+3 -3
View File
@@ -311,7 +311,7 @@ func TestUpdateLifecycle(t *testing.T) {
dbM := dbmock.NewMockStore(gomock.NewController(t))
var publishCalled int64
var publishCalled atomic.Int64
reg := prometheus.NewRegistry()
metrics := agentapi.NewLifecycleMetrics(reg)
@@ -324,7 +324,7 @@ func TestUpdateLifecycle(t *testing.T) {
Log: testutil.Logger(t),
Metrics: metrics,
PublishWorkspaceUpdateFn: func(ctx context.Context, _ uuid.UUID, kind wspubsub.WorkspaceEventKind) error {
atomic.AddInt64(&publishCalled, 1)
publishCalled.Add(1)
return nil
},
}
@@ -384,7 +384,7 @@ func TestUpdateLifecycle(t *testing.T) {
})
require.NoError(t, err)
require.Equal(t, lifecycle, resp)
require.Equal(t, int64(i+1), atomic.LoadInt64(&publishCalled))
require.Equal(t, int64(i+1), publishCalled.Load())
// For future iterations:
agent.StartedAt = expectedStartedAt