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") }