Fix flakey test in file_tests (#1783)

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
This commit is contained in:
Shivam Sandbhor 2022-10-05 20:10:09 +05:30 committed by GitHub
parent af30ba0e3b
commit b203b3f444
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {