MCPcopy Index your code
hub / github.com/coder/coder / TestHeadTailBuffer_LongLineTruncation

Function TestHeadTailBuffer_LongLineTruncation

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

Source from the content-addressed store, hash-verified

144}
145
146func TestHeadTailBuffer_LongLineTruncation(t *testing.T) {
147 t.Parallel()
148
149 buf := agentproc.NewHeadTailBuffer()
150
151 // Write a line longer than MaxLineLength.
152 longLine := strings.Repeat("m", agentproc.MaxLineLength+500)
153 _, err := buf.Write([]byte(longLine + "\n"))
154 require.NoError(t, err)
155
156 out, _ := buf.Output()
157 lines := strings.Split(strings.TrimRight(out, "\n"), "\n")
158 require.Len(t, lines, 1)
159 require.LessOrEqual(t, len(lines[0]), agentproc.MaxLineLength)
160 require.True(t, strings.HasSuffix(lines[0], "... [truncated]"))
161}
162
163func TestHeadTailBuffer_LongLineInTail(t *testing.T) {
164 t.Parallel()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected