MCPcopy Index your code
hub / github.com/riverqueue/river / TestNotifier

Function TestNotifier

internal/notifier/notifier_test.go:32–625  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestNotifier(t *testing.T) {
33 t.Parallel()
34
35 const (
36 testTopic1 = "test_topic1"
37 testTopic2 = "test_topic2"
38 )
39
40 ctx := context.Background()
41
42 type testBundle struct {
43 dbPool *pgxpool.Pool
44 exec riverdriver.Executor
45 schema string
46 }
47
48 type testOpts struct {
49 dbPool *pgxpool.Pool // may be left nil for riversharedtest.DBPool
50 }
51
52 setup := func(t *testing.T, opts *testOpts) (*Notifier, *testBundle) {
53 t.Helper()
54
55 if opts == nil {
56 opts = &testOpts{}
57 }
58
59 var (
60 dbPool = cmp.Or(opts.dbPool, riversharedtest.DBPool(ctx, t))
61 driver = riverpgxv5.New(dbPool)
62 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
63 listener = driver.GetListener(&riverdriver.GetListenenerParams{Schema: schema})
64 )
65
66 notifier := New(riversharedtest.BaseServiceArchetype(t), listener)
67 notifier.testSignals.Init(t)
68
69 return notifier, &testBundle{
70 dbPool: dbPool,
71 exec: driver.GetExecutor(),
72 schema: schema,
73 }
74 }
75
76 start := func(t *testing.T, notifier *Notifier) {
77 t.Helper()
78
79 require.NoError(t, notifier.Start(ctx))
80 t.Cleanup(notifier.Stop)
81 }
82
83 t.Run("StartsAndStops", func(t *testing.T) {
84 t.Parallel()
85
86 notifier, _ := setup(t, nil)
87 start(t, notifier)
88
89 notifier.testSignals.ListeningBegin.WaitOrTimeout()

Callers

nothing calls this directly

Calls 15

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
BaseServiceArchetypeFunction · 0.92
DBPoolCloneFunction · 0.92
LoggerWarnFunction · 0.92
StressFunction · 0.92
WaitOrTimeoutFunction · 0.92
KeysFunction · 0.92
CancellableSleepFunction · 0.92
DurationBetweenFunction · 0.92
NewListenerMockFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…