MCPcopy
hub / github.com/crowdsecurity/crowdsec / TestStartAcquisitionTail

Function TestStartAcquisitionTail

pkg/acquisition/acquisition_test.go:431–462  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

429}
430
431func 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
447READLOOP:
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
464type MockTailError struct {
465 MockTail

Callers

nothing calls this directly

Calls 4

StartAcquisitionFunction · 0.85
KillMethod · 0.80
ErrMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…