MCPcopy Create free account
hub / github.com/coder/coder / TestHeadTailBuffer_MultipleLinesTruncated

Function TestHeadTailBuffer_MultipleLinesTruncated

agent/agentproc/headtail_test.go:322–338  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

320}
321
322func TestHeadTailBuffer_MultipleLinesTruncated(t *testing.T) {
323 t.Parallel()
324
325 buf := agentproc.NewHeadTailBuffer()
326
327 short := "short line\n"
328 long := strings.Repeat("L", agentproc.MaxLineLength+100) + "\n"
329 _, err := buf.Write([]byte(short + long + short))
330 require.NoError(t, err)
331
332 out, _ := buf.Output()
333 lines := strings.Split(strings.TrimRight(out, "\n"), "\n")
334 require.Len(t, lines, 3)
335 require.Equal(t, "short line", lines[0])
336 require.True(t, strings.HasSuffix(lines[1], "... [truncated]"))
337 require.Equal(t, "short line", lines[2])
338}

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.95
OutputMethod · 0.95
NewHeadTailBufferFunction · 0.92
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected