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

Function TestBaseStartStopFunc

rivershared/startstop/start_stop_test.go:158–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestBaseStartStopFunc(t *testing.T) {
159 t.Parallel()
160
161 makeFunc := func(t *testing.T) serviceWithStopped {
162 t.Helper()
163
164 // Some simple state in the service which a started service taints. The
165 // purpose of this variable is to allow us to detect a data race allowed by
166 // BaseStartStop.
167 var state bool
168
169 return StartStopFunc(func(ctx context.Context, shouldStart bool, started, stopped func()) error {
170 if !shouldStart {
171 return nil
172 }
173
174 go func() {
175 started()
176 defer stopped()
177 state = true
178 t.Logf("State: %t", state) // here so variable doesn't register as unused
179 <-ctx.Done()
180 }()
181
182 return nil
183 })
184 }
185
186 testService(t, makeFunc)
187}
188
189func TestErrStop(t *testing.T) {
190 t.Parallel()

Callers

nothing calls this directly

Calls 5

StartStopFuncFunction · 0.85
DoneMethod · 0.80
testServiceFunction · 0.70
HelperMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…