Skip to content

Commit 015584e

Browse files
committed
test(lifecycle): use atomic.Int32 instead of int32+atomic helpers
CI runs golangci-lint v2.11.4 which has the modernize check enabled and rejected: pkg/tools/lifecycle/supervisor_test.go:60:2: atomic: var calls int32 may be simplified using atomic.Int32 (modernize) Switch scriptedConnector.calls to atomic.Int32 with .Add()/.Load() methods. Pure cleanup; same behaviour. Assisted-By: docker-agent
1 parent 247e137 commit 015584e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎pkg/tools/lifecycle/supervisor_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type scriptedConnector struct {
5757
mu sync.Mutex
5858
scripts []scriptStep
5959
idx int
60-
calls int32
60+
calls atomic.Int32
6161
delivered chan *fakeSession
6262
}
6363

@@ -74,7 +74,7 @@ func newScriptedConnector(steps ...scriptStep) *scriptedConnector {
7474
}
7575

7676
func (c *scriptedConnector) Connect(context.Context) (lifecycle.Session, error) {
77-
atomic.AddInt32(&c.calls, 1)
77+
c.calls.Add(1)
7878
c.mu.Lock()
7979
if c.idx >= len(c.scripts) {
8080
c.mu.Unlock()
@@ -91,7 +91,7 @@ func (c *scriptedConnector) Connect(context.Context) (lifecycle.Session, error)
9191
return step.session, nil
9292
}
9393

94-
func (c *scriptedConnector) Calls() int { return int(atomic.LoadInt32(&c.calls)) }
94+
func (c *scriptedConnector) Calls() int { return int(c.calls.Load()) }
9595

9696
// fastBackoff is a minimal backoff for tests so we don't sit in time.Sleep.
9797
var fastBackoff = lifecycle.Backoff{

0 commit comments

Comments
 (0)