MCPcopy Create free account
hub / github.com/riverqueue/river / testService

Function testService

rivershared/startstop/start_stop_test.go:52–150  ·  view source on GitHub ↗
(t *testing.T, newService func(t *testing.T) serviceWithStopped)

Source from the content-addressed store, hash-verified

50}
51
52func testService(t *testing.T, newService func(t *testing.T) serviceWithStopped) {
53 t.Helper()
54
55 ctx := context.Background()
56
57 type testBundle struct{}
58
59 setup := func(t *testing.T) (serviceWithStopped, *testBundle) {
60 t.Helper()
61
62 return newService(t), &testBundle{}
63 }
64
65 t.Run("StopAndStart", func(t *testing.T) {
66 t.Parallel()
67
68 service, _ := setup(t)
69
70 require.NoError(t, service.Start(ctx))
71 service.Stop()
72 })
73
74 t.Run("DoubleStop", func(t *testing.T) {
75 t.Parallel()
76
77 service, _ := setup(t)
78
79 require.NoError(t, service.Start(ctx))
80 service.Stop()
81 service.Stop()
82 })
83
84 t.Run("StopWithoutStart", func(t *testing.T) {
85 t.Parallel()
86
87 service, _ := setup(t)
88
89 service.Stop()
90 })
91
92 t.Run("StartedChannel", func(t *testing.T) {
93 t.Parallel()
94
95 service, _ := setup(t)
96
97 require.NoError(t, service.Start(ctx))
98 t.Cleanup(service.Stop)
99
100 riversharedtest.WaitOrTimeout(t, service.Started())
101 })
102
103 t.Run("StoppedChannel", func(t *testing.T) {
104 t.Parallel()
105
106 service, _ := setup(t)
107
108 require.NoError(t, service.Start(ctx))
109

Callers 3

TestBaseStartStopFunction · 0.70
TestBaseStartStopFuncFunction · 0.70
TestWithStopInitFunction · 0.70

Calls 8

WaitOrTimeoutFunction · 0.92
CleanupMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65
StartMethod · 0.65
StopMethod · 0.65
StartedMethod · 0.65
StoppedMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…