MM-19022: Convert config/watcher_test.go t.Fatal calls into require calls (#12524)
* Convert config/watcher_test.go t.Fatal calls into require calls * Moved wasCalled to a public helper function Now the testutils package has a new function WasCalled that can be used by anywhere.
Этот коммит содержится в:
коммит произвёл
Miguel de la Cruz
родитель
013a81a33d
Коммит
8ab0e80b77
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/utils/fileutils"
|
||||
)
|
||||
@@ -27,3 +28,15 @@ func ReadTestFile(name string) ([]byte, error) {
|
||||
return data.Bytes(), nil
|
||||
}
|
||||
}
|
||||
|
||||
// WasCalled reports whether a given callback channel was called
|
||||
// within the specified time duration or not.
|
||||
func WasCalled(c chan bool, duration time.Duration) bool {
|
||||
wasCalled := false
|
||||
select {
|
||||
case <-c:
|
||||
wasCalled = true
|
||||
case <-time.After(duration):
|
||||
}
|
||||
return wasCalled
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user