diff --git a/utils/file_it_test.go b/utils/file_it_test.go index 58b4033ab..9f38a9a93 100644 --- a/utils/file_it_test.go +++ b/utils/file_it_test.go @@ -22,9 +22,11 @@ along with this program. If not, see package utils import ( + "bytes" "fmt" "os" "path" + "strings" "testing" "github.com/fsnotify/fsnotify" @@ -63,6 +65,10 @@ func testWatchWatcherError(t *testing.T) { } func testWatchWatcherEvents(t *testing.T) { + tmpLog := Logger + t.Cleanup(func() { Logger = tmpLog }) + buf := new(bytes.Buffer) + Logger = NewStdLoggerWithWriter(buf, "", 4) watcher, err := fsnotify.NewWatcher() if err != nil { t.Fatal(err) @@ -82,9 +88,12 @@ func testWatchWatcherEvents(t *testing.T) { } return fmt.Errorf("Can't match path") } - expected := "Can't match path" - if err := watch(EmptyString, EmptyString, f, watcher, stopWatching); err == nil || err.Error() != expected { - t.Errorf("Expected %+v, received %+v", expected, err) + if err := watch(EmptyString, EmptyString, f, watcher, stopWatching); err != nil { + t.Error(err) + } + expLog := `[WARNING] <> processing path , error: ` + if !strings.Contains(buf.String(), expLog) { + t.Errorf("expected %q to be present, received:\n%s", expLog, buf.String()) } }