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

Function TestHeadTailBuffer_TruncationInfoFields

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

Source from the content-addressed store, hash-verified

213}
214
215func TestHeadTailBuffer_TruncationInfoFields(t *testing.T) {
216 t.Parallel()
217
218 buf := agentproc.NewHeadTailBufferSized(10, 10)
219
220 // Write enough to cause omission.
221 data := strings.Repeat("D", 50)
222 _, err := buf.Write([]byte(data))
223 require.NoError(t, err)
224
225 _, info := buf.Output()
226 require.NotNil(t, info)
227 require.Equal(t, 50, info.OriginalBytes)
228 require.Equal(t, 30, info.OmittedBytes)
229 require.Equal(t, "head_tail", info.Strategy)
230 // RetainedBytes is the length of the formatted output
231 // string including the omission marker.
232 require.Greater(t, info.RetainedBytes, 0)
233}
234
235func TestHeadTailBuffer_MultipleSmallWrites(t *testing.T) {
236 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewHeadTailBufferSizedFunction · 0.92
WriteMethod · 0.65
OutputMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected