From 59906b06e8c3678c6e556e7459ae668d9ef2a946 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 18 Mar 2023 15:37:42 +0100 Subject: [PATCH] Fix: Tests broken after last change Signed-off-by: Knut Ahlers --- file/watcher_test.go | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/file/watcher_test.go b/file/watcher_test.go index 323530b..91220b0 100644 --- a/file/watcher_test.go +++ b/file/watcher_test.go @@ -25,39 +25,39 @@ func TestWatcherCheckHash(t *testing.T) { w, err := newWatcher(testFile, time.Second, WatcherCheckHash(sha256.New)) require.NoError(t, err, "initial check should not error on non existing file") - evt, err := w.runStateChecks(false) + evt, err := w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventInvalid, evt, "expect invalid as file is still missing") err = os.WriteFile(testFile, []byte("test"), 0o644) require.NoError(t, err, "creating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as file now exists and has hash change") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect no change as the file has the same hash") err = os.WriteFile(testFile, []byte("hello world"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as file was modified") err = os.Remove(testFile) require.NoError(t, err, "deleting test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventInvalid, evt, "expect check to be invalid as file is no longer there") err = os.WriteFile(testFile, []byte("hello world"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect change as file has same hash") } @@ -76,18 +76,18 @@ func TestWatcherCheckMtime(t *testing.T) { w, err := newWatcher(testFile, time.Second, WatcherCheckMtime) require.NoError(t, err, "initial check should not error on non existing file") - evt, err := w.runStateChecks(false) + evt, err := w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventInvalid, evt, "expect invalid as file is still missing") err = os.WriteFile(testFile, []byte("test"), 0o644) require.NoError(t, err, "creating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as file now exists and has mtime change") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect no change as the file has the same mtime") @@ -96,14 +96,14 @@ func TestWatcherCheckMtime(t *testing.T) { err = os.WriteFile(testFile, []byte("hello world"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as file was modified") err = os.Remove(testFile) require.NoError(t, err, "deleting test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventInvalid, evt, "expect check to be invalid as file is no longer there") @@ -112,7 +112,7 @@ func TestWatcherCheckMtime(t *testing.T) { err = os.WriteFile(testFile, []byte("hello world"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as file is newer") } @@ -131,25 +131,25 @@ func TestWatcherCheckPresence(t *testing.T) { w, err := newWatcher(testFile, time.Second, WatcherCheckPresence) require.NoError(t, err, "initial check should not error on non existing file") - evt, err := w.runStateChecks(false) + evt, err := w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect no change as file is still missing") err = os.WriteFile(testFile, []byte("test"), 0o644) require.NoError(t, err, "creating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileAppeared, evt, "expect check to state file is now there") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect check to state nothing changed") err = os.Remove(testFile) require.NoError(t, err, "deleting test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventFileVanished, evt, "expect check to state file vanished again") } @@ -168,42 +168,42 @@ func TestWatcherCheckSize(t *testing.T) { w, err := newWatcher(testFile, time.Second, WatcherCheckSize) require.NoError(t, err, "initial check should not error on non existing file") - evt, err := w.runStateChecks(false) + evt, err := w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventInvalid, evt, "expect invalid as file is still missing") err = os.WriteFile(testFile, []byte("test"), 0o644) require.NoError(t, err, "creating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as file has now 4 instead of 0 bytes") err = os.WriteFile(testFile, []byte("tset"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect no change as the file has the same size") err = os.WriteFile(testFile, []byte("hello world"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventFileModified, evt, "expect change as we went from 4 to 11 chars") err = os.Remove(testFile) require.NoError(t, err, "deleting test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on non existing file") assert.Equal(t, WatcherEventInvalid, evt, "expect check to be invalid as file is no longer there") err = os.WriteFile(testFile, []byte("hello world"), 0o644) require.NoError(t, err, "updating test file") - evt, err = w.runStateChecks(false) + evt, err = w.runStateChecks() require.NoError(t, err, "check should not error on existing file") assert.Equal(t, WatcherEventNoChange, evt, "expect no change as we restored the file with same content") }