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.
Этот коммит содержится в:
Agniva De Sarker
2019-10-02 22:27:43 +05:30
коммит произвёл Miguel de la Cruz
родитель 013a81a33d
Коммит 8ab0e80b77
2 изменённых файлов: 17 добавлений и 10 удалений

Просмотреть файл

@@ -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
}