(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func TestHeadTailBuffer_ConcurrentWrites(t *testing.T) { |
| 185 | t.Parallel() |
| 186 | |
| 187 | buf := agentproc.NewHeadTailBuffer() |
| 188 | |
| 189 | const goroutines = 10 |
| 190 | const writes = 1000 |
| 191 | var wg sync.WaitGroup |
| 192 | wg.Add(goroutines) |
| 193 | |
| 194 | for g := range goroutines { |
| 195 | go func() { |
| 196 | defer wg.Done() |
| 197 | line := fmt.Sprintf("goroutine-%d: data\n", g) |
| 198 | for range writes { |
| 199 | _, err := buf.Write([]byte(line)) |
| 200 | assert.NoError(t, err) |
| 201 | } |
| 202 | }() |
| 203 | } |
| 204 | |
| 205 | wg.Wait() |
| 206 | |
| 207 | // Verify totals are consistent. |
| 208 | require.Greater(t, buf.TotalWritten(), 0) |
| 209 | require.Greater(t, buf.Len(), 0) |
| 210 | |
| 211 | out, _ := buf.Output() |
| 212 | require.NotEmpty(t, out) |
| 213 | } |
| 214 | |
| 215 | func TestHeadTailBuffer_TruncationInfoFields(t *testing.T) { |
| 216 | t.Parallel() |
nothing calls this directly
no test coverage detected