(t *testing.T)
| 41 | } |
| 42 | |
| 43 | func 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 | |
| 67 | func TestHeadTailBuffer_HeadPlusTailNoOmission(t *testing.T) { |
| 68 | t.Parallel() |
nothing calls this directly
no test coverage detected