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

Function TestHeadTailBuffer_LongLineInTail

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

Source from the content-addressed store, hash-verified

161}
162
163func TestHeadTailBuffer_LongLineInTail(t *testing.T) {
164 t.Parallel()
165
166 // Use small buffers so we can force data into the tail.
167 buf := agentproc.NewHeadTailBufferSized(20, 5000)
168
169 // Fill head with short data.
170 _, err := buf.Write([]byte("head data goes here\n"))
171 require.NoError(t, err)
172
173 // Now write a very long line into the tail.
174 longLine := strings.Repeat("T", agentproc.MaxLineLength+100)
175 _, err = buf.Write([]byte(longLine + "\n"))
176 require.NoError(t, err)
177
178 out, info := buf.Output()
179 require.NotNil(t, info)
180 // The long line in the tail should be truncated.
181 require.Contains(t, out, "... [truncated]")
182}
183
184func TestHeadTailBuffer_ConcurrentWrites(t *testing.T) {
185 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewHeadTailBufferSizedFunction · 0.92
WriteMethod · 0.65
OutputMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected