newDetectorTestEnv creates a new test environment with a started detector.
(ctx context.Context, t *testing.T)
| 46 | |
| 47 | // newDetectorTestEnv creates a new test environment with a started detector. |
| 48 | func newDetectorTestEnv(ctx context.Context, t *testing.T) *detectorTestEnv { |
| 49 | t.Helper() |
| 50 | db, ps := dbtestutil.NewDB(t) |
| 51 | log := testutil.Logger(t) |
| 52 | tickCh := make(chan time.Time) |
| 53 | statsCh := make(chan jobreaper.Stats) |
| 54 | |
| 55 | detector := jobreaper.New(ctx, wrapDBAuthz(db, log), ps, log, tickCh).WithStatsChannel(statsCh) |
| 56 | detector.Start() |
| 57 | |
| 58 | return &detectorTestEnv{ |
| 59 | t: t, |
| 60 | DB: db, |
| 61 | Pubsub: ps, |
| 62 | detector: detector, |
| 63 | tickCh: tickCh, |
| 64 | statsCh: statsCh, |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // tick sends a tick with the given time and returns the stats from the |
| 69 | // detector run. It respects context cancellation to avoid blocking forever |
no test coverage detected