(t *testing.T)
| 429 | } |
| 430 | |
| 431 | func TestStartAcquisitionTail(t *testing.T) { |
| 432 | ctx := t.Context() |
| 433 | sources := []types.DataSource{ |
| 434 | &MockTail{}, |
| 435 | } |
| 436 | out := make(chan pipeline.Event) |
| 437 | acquisTomb := tomb.Tomb{} |
| 438 | |
| 439 | go func() { |
| 440 | if err := StartAcquisition(ctx, sources, out, &acquisTomb); err != nil { |
| 441 | t.Error("unexpected error") |
| 442 | } |
| 443 | }() |
| 444 | |
| 445 | count := 0 |
| 446 | |
| 447 | READLOOP: |
| 448 | for { |
| 449 | select { |
| 450 | case <-out: |
| 451 | count++ |
| 452 | case <-time.After(1 * time.Second): |
| 453 | break READLOOP |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | assert.Equal(t, 10, count) |
| 458 | |
| 459 | acquisTomb.Kill(nil) |
| 460 | time.Sleep(1 * time.Second) |
| 461 | require.NoError(t, acquisTomb.Err(), "tomb is not dead") |
| 462 | } |
| 463 | |
| 464 | type MockTailError struct { |
| 465 | MockTail |
nothing calls this directly
no test coverage detected
searching dependent graphs…