From c5cc1120a9a2ce5043ca5650c9e3acce615ef1e7 Mon Sep 17 00:00:00 2001 From: ThinkChaos Date: Thu, 30 Nov 2023 20:25:21 -0500 Subject: [PATCH] squash: remove `TmpFolder.ReadDir` and partially revert querylog test --- helpertest/tmpdata.go | 7 ------- querylog/file_writer_test.go | 9 +++++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/helpertest/tmpdata.go b/helpertest/tmpdata.go index a4c8df4a..c8fad1a7 100644 --- a/helpertest/tmpdata.go +++ b/helpertest/tmpdata.go @@ -105,13 +105,6 @@ func (tf *TmpFolder) JoinPath(name string) string { return filepath.Join(tf.Path, name) } -func (tf *TmpFolder) ReadDir() []fs.DirEntry { - files, err := os.ReadDir(tf.Path) - Expect(err).Should(Succeed()) - - return files -} - func (tf *TmpFolder) createFile(name string) (*os.File, *TmpFile) { var ( f *os.File diff --git a/querylog/file_writer_test.go b/querylog/file_writer_test.go index 91073ab0..583d6217 100644 --- a/querylog/file_writer_test.go +++ b/querylog/file_writer_test.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "io/fs" "os" "time" @@ -115,11 +116,15 @@ var _ = Describe("FileWriter", func() { }) }) - Expect(tmpDir.ReadDir()).Should(HaveLen(2)) + Eventually(func(g Gomega) ([]fs.DirEntry, error) { + return os.ReadDir(tmpDir.Path) + }, "20s", "1s").Should(HaveLen(2)) writer.CleanUp() - Expect(tmpDir.ReadDir()).Should(HaveLen(1)) + Eventually(func(g Gomega) ([]fs.DirEntry, error) { + return os.ReadDir(tmpDir.Path) + }, "20s", "1s").Should(HaveLen(1)) }) }) })