mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 14:29:40 +02:00
fix(adminmonitor): fix a data race in a unit test EE-2714 (#6627)
This commit is contained in:
parent
9a42d4c506
commit
78f7cd0d6c
1 changed files with 8 additions and 1 deletions
|
@ -35,9 +35,15 @@ func Test_start_shouldFatalAfterTimeout_ifNotInitialized(t *testing.T) {
|
|||
|
||||
datastore := i.NewDatastore(i.WithUsers([]portainer.User{}))
|
||||
|
||||
ch := make(chan struct{})
|
||||
var fataled bool
|
||||
origLogFatalf := logFatalf
|
||||
logFatalf = func(s string, v ...interface{}) { fataled = true }
|
||||
|
||||
logFatalf = func(s string, v ...interface{}) {
|
||||
fataled = true
|
||||
close(ch)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
logFatalf = origLogFatalf
|
||||
}()
|
||||
|
@ -45,6 +51,7 @@ func Test_start_shouldFatalAfterTimeout_ifNotInitialized(t *testing.T) {
|
|||
monitor := New(timeout, datastore, context.Background())
|
||||
monitor.Start()
|
||||
<-time.After(2 * timeout)
|
||||
<-ch
|
||||
|
||||
assert.True(t, fataled, "monitor should been timeout and fatal")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue