From b203b3f444d48b786cc6bc7f0183071565168de2 Mon Sep 17 00:00:00 2001 From: Shivam Sandbhor Date: Wed, 5 Oct 2022 20:10:09 +0530 Subject: [PATCH] Fix flakey test in file_tests (#1783) Signed-off-by: Shivam Sandbhor --- pkg/acquisition/modules/file/file_test.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/acquisition/modules/file/file_test.go b/pkg/acquisition/modules/file/file_test.go index 5e88c1cfb..06653fbe1 100644 --- a/pkg/acquisition/modules/file/file_test.go +++ b/pkg/acquisition/modules/file/file_test.go @@ -213,7 +213,7 @@ filename: test_files/test_delete.log`, }) tomb := tomb.Tomb{} - out := make(chan types.Event) + out := make(chan types.Event, 100) f := fileacquisition.FileSource{} if tc.setup != nil { @@ -229,22 +229,8 @@ filename: test_files/test_delete.log`, if tc.afterConfigure != nil { tc.afterConfigure() } - - actualLines := 0 - if tc.expectedLines != 0 { - go func() { - for { - select { - case <-out: - actualLines++ - case <-time.After(2 * time.Second): - return - } - } - }() - } - err = f.OneShotAcquisition(out, &tomb) + actualLines := len(out) cstest.RequireErrorContains(t, err, tc.expectedErr) if tc.expectedLines != 0 {