MCPcopy Index your code
hub / github.com/coder/coder / TestHeartbeat

Function TestHeartbeat

coderd/provisionerdserver/provisionerdserver_test.go:286–312  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

284}
285
286func TestHeartbeat(t *testing.T) {
287 t.Parallel()
288
289 numBeats := 3
290 ctx := testutil.Context(t, testutil.WaitShort)
291 heartbeatChan := make(chan struct{})
292 heartbeatFn := func(hbCtx context.Context) error {
293 t.Log("heartbeat")
294 select {
295 case <-hbCtx.Done():
296 return hbCtx.Err()
297 case heartbeatChan <- struct{}{}:
298 return nil
299 }
300 }
301 //nolint:dogsled
302 _, _, _, _ = setup(t, false, &overrides{
303 ctx: ctx,
304 heartbeatFn: heartbeatFn,
305 heartbeatInterval: testutil.IntervalFast,
306 })
307
308 for i := 0; i < numBeats; i++ {
309 testutil.TryReceive(ctx, t, heartbeatChan)
310 }
311 // goleak.VerifyTestMain ensures that the heartbeat goroutine does not leak
312}
313
314func TestAcquireJob(t *testing.T) {
315 t.Parallel()

Callers

nothing calls this directly

Calls 6

ContextFunction · 0.92
TryReceiveFunction · 0.92
LogMethod · 0.80
ErrMethod · 0.80
setupFunction · 0.70
DoneMethod · 0.45

Tested by

no test coverage detected