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

Function TestHeadTailBuffer_ExactlyHeadSize

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

Source from the content-addressed store, hash-verified

41}
42
43func TestHeadTailBuffer_ExactlyHeadSize(t *testing.T) {
44 t.Parallel()
45
46 buf := agentproc.NewHeadTailBuffer()
47
48 // Build data that is exactly MaxHeadBytes using short
49 // lines so that line truncation does not apply.
50 line := strings.Repeat("x", 79) + "\n" // 80 bytes per line
51 count := agentproc.MaxHeadBytes / len(line)
52 pad := agentproc.MaxHeadBytes - (count * len(line))
53 data := strings.Repeat(line, count) + strings.Repeat("y", pad)
54 require.Equal(t, agentproc.MaxHeadBytes, len(data),
55 "test data must be exactly MaxHeadBytes")
56
57 n, err := buf.Write([]byte(data))
58 require.NoError(t, err)
59 require.Equal(t, agentproc.MaxHeadBytes, n)
60
61 out, info := buf.Output()
62 require.Equal(t, data, out)
63 require.Nil(t, info, "output fitting in head should not be truncated")
64 require.Equal(t, agentproc.MaxHeadBytes, buf.Len())
65}
66
67func TestHeadTailBuffer_HeadPlusTailNoOmission(t *testing.T) {
68 t.Parallel()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected