Explorar o código

Fix flakey test in file_tests (#1783)

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Shivam Sandbhor %!s(int64=2) %!d(string=hai) anos
pai
achega
b203b3f444
Modificáronse 1 ficheiros con 2 adicións e 16 borrados
  1. 2 16
      pkg/acquisition/modules/file/file_test.go

+ 2 - 16
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 {