55 "context"
66 "fmt"
77 "os"
8+ "sync/atomic"
89 "testing"
910 "time"
1011
@@ -496,7 +497,7 @@ func TestRunCmdWithMockFactory(t *testing.T) {
496497
497498 t .Run ("Successful run with mock" , func (t * testing.T ) {
498499 // Track if service was registered at least once
499- registered := false
500+ var registered atomic. Bool
500501
501502 // Create a mock agent that simulates a service
502503 mockAgent := & MockAgent {
@@ -509,7 +510,7 @@ func TestRunCmdWithMockFactory(t *testing.T) {
509510 },
510511 ServiceRegisterFunc : func (reg * api.AgentServiceRegistration ) error {
511512 // Verify that new tags were added
512- registered = true
513+ registered . Store ( true )
513514 assert .Contains (t , reg .Tags , "existing-tag" )
514515 assert .Contains (t , reg .Tags , "test-tag1" )
515516 assert .Contains (t , reg .Tags , "test-tag2" )
@@ -553,7 +554,7 @@ func TestRunCmdWithMockFactory(t *testing.T) {
553554 time .Sleep (250 * time .Millisecond )
554555
555556 // The command should have registered the service at least once
556- assert .True (t , registered , "Service should have been registered at least once" )
557+ assert .True (t , registered . Load () , "Service should have been registered at least once" )
557558
558559 // Note: The run command runs forever, so we can't test it finishing cleanly
559560 // This test verifies it starts correctly and processes at least one update
0 commit comments