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

Function TestHeadTailBuffer_BytesReturnsCopy

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

Source from the content-addressed store, hash-verified

278}
279
280func TestHeadTailBuffer_BytesReturnsCopy(t *testing.T) {
281 t.Parallel()
282
283 buf := agentproc.NewHeadTailBuffer()
284 _, err := buf.Write([]byte("original"))
285 require.NoError(t, err)
286
287 b := buf.Bytes()
288 require.Equal(t, []byte("original"), b)
289
290 // Mutating the returned slice should not affect the
291 // buffer.
292 b[0] = 'X'
293 require.Equal(t, []byte("original"), buf.Bytes())
294}
295
296func TestHeadTailBuffer_RingBufferWraparound(t *testing.T) {
297 t.Parallel()

Callers

nothing calls this directly

Calls 4

WriteMethod · 0.95
BytesMethod · 0.95
NewHeadTailBufferFunction · 0.92
EqualMethod · 0.45

Tested by

no test coverage detected