fix(scheduler): fix a data race in a scheduler unit test EE-2715 (#6628)

pull/6658/head
andres-portainer 2022-03-15 09:52:58 -03:00 committed by GitHub
parent 78f7cd0d6c
commit f8fd28bb61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -53,12 +53,15 @@ func Test_JobShouldStop_UponError(t *testing.T) {
defer s.Shutdown()
var acc int
ch := make(chan struct{})
s.StartJobEvery(jobInterval, func() error {
acc++
close(ch)
return fmt.Errorf("failed")
})
<-time.After(3 * jobInterval)
<-ch
assert.Equal(t, 1, acc, "job stop after the first run because it returns an error")
}