From ebafb713c0c8436df778775a1f1ba60655f7417d Mon Sep 17 00:00:00 2001 From: John Roesler Date: Wed, 26 Nov 2025 13:34:49 -0600 Subject: [PATCH] add a mutex --- scheduler_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scheduler_test.go b/scheduler_test.go index bef7609..3c71346 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -585,6 +585,7 @@ func TestScheduler_Start(t *testing.T) { s := newTestScheduler(t) var counter int + var mu sync.Mutex _, err := s.NewJob( DurationJob( @@ -592,19 +593,19 @@ func TestScheduler_Start(t *testing.T) { ), NewTask( func() { + mu.Lock() counter++ + mu.Unlock() }, ), ) require.NoError(t, err) s.Start() - time.Sleep(100 * time.Millisecond) s.Start() - time.Sleep(100 * time.Millisecond) s.Start() - time.Sleep(800 * time.Millisecond) + time.Sleep(1000 * time.Millisecond) require.NoError(t, s.Shutdown())