MCPcopy
hub / github.com/google/mtail / TestHandleLogUpdatePartialLine

Function TestHandleLogUpdatePartialLine

internal/tailer/tail_test.go:152–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestHandleLogUpdatePartialLine(t *testing.T) {
153 ta := makeTestTail(t)
154
155 logfile := filepath.Join(ta.tmpDir, "log")
156 f := testutil.TestOpenFile(t, logfile)
157 defer f.Close()
158
159 testutil.FatalIfErr(t, ta.TailPath(logfile))
160 ta.awakenStreams(1, 1) // ensure we've hit an EOF before writing starts
161
162 testutil.WriteString(t, f, "a")
163 ta.awakenStreams(1, 1)
164
165 testutil.WriteString(t, f, "b")
166 ta.awakenStreams(1, 1)
167
168 testutil.WriteString(t, f, "\n")
169 ta.awakenStreams(1, 1)
170
171 ta.stop()
172
173 received := testutil.LinesReceived(ta.lines)
174 expected := []*logline.LogLine{
175 {Context: context.Background(), Filename: logfile, Line: "ab"},
176 }
177 testutil.ExpectNoDiff(t, expected, received, testutil.IgnoreFields(logline.LogLine{}, "Context"))
178}
179
180// Test that broken files are skipped.
181func TestTailerUnreadableFile(t *testing.T) {

Callers

nothing calls this directly

Calls 8

TestOpenFileFunction · 0.92
FatalIfErrFunction · 0.92
WriteStringFunction · 0.92
LinesReceivedFunction · 0.92
ExpectNoDiffFunction · 0.92
IgnoreFieldsFunction · 0.92
makeTestTailFunction · 0.85
TailPathMethod · 0.80

Tested by

no test coverage detected