From 47fb574aef2d21ae31f0a1bea9e1a6ab71a66bed Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Wed, 26 Feb 2025 18:40:11 +0200 Subject: [PATCH] revise failing integration test failing due to 56dfa4ee21bff7663501ebbab554775d1e55346e warning error is not returned anymore, only logged --- utils/file_it_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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()) } }