ctx should start after writting lines
@@ -248,9 +248,9 @@ func TestRun(t *testing.T) {
// This test checks searchLog keeps reading until EOL even if ctx is cancelled.
// To guarantee to read at least once, a timeout sec
// should be choice it is greater than reading the state file.
- ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond)
- defer cancel()
fh.WriteString("OK\nFATAL\nFATAL\n")
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
+ defer cancel()
expected := time.Now().Add(30 * time.Millisecond)
w, c, errLines, err := opts.searchLog(ctx, logf)
