revise failing integration test

failing due to 56dfa4ee21
warning error is not returned anymore, only logged
This commit is contained in:
ionutboangiu
2025-02-26 18:40:11 +02:00
committed by Dan Christian Bogos
parent 56dfa4ee21
commit 47fb574aef

View File

@@ -22,9 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
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 </tmp/file.txt>, error: <Can't match path>`
if !strings.Contains(buf.String(), expLog) {
t.Errorf("expected %q to be present, received:\n%s", expLog, buf.String())
}
}