From f254a96d00f1f66de95d0f4b6fe975c311fe4dad Mon Sep 17 00:00:00 2001 From: mstmdev Date: Wed, 11 Jan 2023 05:00:15 +0800 Subject: [PATCH] test(config/file): fix the unit test TestFile being blocked on Windows --- config/file/file_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/file/file_test.go b/config/file/file_test.go index ac6ad8435..b70ff66fe 100644 --- a/config/file/file_test.go +++ b/config/file/file_test.go @@ -114,11 +114,14 @@ func testWatchFile(t *testing.T, path string) { if err != nil { t.Error(err) } - defer f.Close() _, err = f.WriteString(_testJSONUpdate) if err != nil { t.Error(err) } + if err = f.Close(); err != nil { + t.Fatalf("close file error(%v)", err) + } + kvs, err := watch.Next() if err != nil { t.Errorf("watch.Next() error(%v)", err) @@ -163,11 +166,13 @@ func testWatchDir(t *testing.T, path, file string) { if err != nil { t.Error(err) } - defer f.Close() _, err = f.WriteString(_testJSONUpdate) if err != nil { t.Error(err) } + if err = f.Close(); err != nil { + t.Fatalf("close file error(%v)", err) + } kvs, err := watch.Next() if err != nil {