diff options
| author | Shulhan <ms@kilabit.info> | 2022-08-20 22:54:18 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-08-20 22:54:18 +0700 |
| commit | ad218607b8394620c80b8779b1ff57b1219ee94b (patch) | |
| tree | 816225a82ac5684d254dbe2504761806a0453c20 | |
| parent | c4a836ba29422c0c4bdc45e955fc623c5432d49b (diff) | |
| download | ciigo-ad218607b8394620c80b8779b1ff57b1219ee94b.tar.xz | |
all: try to fix test that sometimes fail inside container
When the test running we create directory testdata/watcher, create
a new file testdata/watcher/index.adoc and expect that the modify time
for testdata/watcher is changes.
Except that sometimes it is not. The modification time of directory
watcher before and after the file created most of times equal and this
cause the test wait indifinitely and fail.
This changes add 1 second delay before creating file inside directory
to make sure that the modification time changes.
| -rw-r--r-- | watcher_test.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/watcher_test.go b/watcher_test.go index 89644e5..31d221a 100644 --- a/watcher_test.go +++ b/watcher_test.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "testing" + "time" "github.com/shuLhan/share/lib/test" ) @@ -77,6 +78,11 @@ func testCreate(t *testing.T) { ) testFileAdoc = filepath.Join(testWatcher.dir, `index.adoc`) + + // Let the OS sync the file system before we create new file, + // otherwise the modtime for fs.Root does not changes. + time.Sleep(1 * time.Second) + testAdocFile, err = os.Create(testFileAdoc) if err != nil { t.Fatal(err) |
