diff --git a/internal/tailer/file_test.go b/internal/tailer/file_test.go index 18593e15f..6a12cf891 100644 --- a/internal/tailer/file_test.go +++ b/internal/tailer/file_test.go @@ -49,10 +49,8 @@ func TestReadPartial(t *testing.T) { if f.partial.String() != "" { t.Errorf("partial line not empty: %q", f.partial) } - _, err = fd.WriteString("o") - testutil.FatalIfErr(t, err) - _, err = fd.WriteString("hi") - testutil.FatalIfErr(t, err) + testutil.WriteString(t, fd, "o") + testutil.WriteString(t, fd, "hi") // memmapfs shares data structure here and in code under test so reset the file offset _, err = fd.Seek(0, 0) testutil.FatalIfErr(t, err) @@ -66,8 +64,7 @@ func TestReadPartial(t *testing.T) { // reset the cursor again _, err = fd.Seek(3, io.SeekStart) testutil.FatalIfErr(t, err) - _, err = fd.WriteString("\n") - testutil.FatalIfErr(t, err) + testutil.WriteString(t, fd, "\n") _, err = fd.Seek(-1, io.SeekEnd) testutil.FatalIfErr(t, err) err = f.Read() diff --git a/internal/tailer/tail_test.go b/internal/tailer/tail_test.go index 69d170b74..87dd7213e 100644 --- a/internal/tailer/tail_test.go +++ b/internal/tailer/tail_test.go @@ -74,10 +74,7 @@ func TestHandleLogUpdate(t *testing.T) { } wg.Add(4) - _, err = f.WriteString("a\nb\nc\nd\n") - if err != nil { - t.Fatal(err) - } + testutil.WriteString(t, f, "a\nb\nc\nd\n") // f.Seek(0, 0) w.InjectUpdate(logfile) @@ -183,15 +180,12 @@ func TestHandleLogUpdatePartialLine(t *testing.T) { t.Fatal(err) } - _, err = f.WriteString("a") - if err != nil { - t.Fatal(err) - } + testutil.WriteString(t, f, "a") //f.Seek(0, 0) w.InjectUpdate(logfile) //f.Seek(1, 0) - _, err = f.WriteString("b") + testutil.WriteString(t, f, "b") if err != nil { t.Error(err) } @@ -199,10 +193,7 @@ func TestHandleLogUpdatePartialLine(t *testing.T) { w.InjectUpdate(logfile) //f.Seek(2, 0) - _, err = f.WriteString("\n") - if err != nil { - t.Error(err) - } + testutil.WriteString(t, f, "\n") //f.Seek(2, 0) w.InjectUpdate(logfile)