MCPcopy Create free account
hub / github.com/coder/coder / TestCheckProgress

Function TestCheckProgress

coderd/healthcheck/healthcheck_test.go:277–341  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

275}
276
277func TestCheckProgress(t *testing.T) {
278 t.Parallel()
279
280 t.Run("Summary", func(t *testing.T) {
281 t.Parallel()
282
283 mClock := quartz.NewMock(t)
284 progress := healthcheck.Progress{Clock: mClock}
285
286 // Start some checks
287 progress.Start("Database")
288 progress.Start("DERP")
289 progress.Start("AccessURL")
290
291 // Advance time to simulate check duration
292 mClock.Advance(100 * time.Millisecond)
293
294 // Complete some checks
295 progress.Complete("Database")
296 progress.Complete("AccessURL")
297
298 summary := progress.Summary()
299
300 // Verify completed and running checks are listed with duration / elapsed
301 assert.Equal(t, summary, "Completed: AccessURL (100ms), Database (100ms). Still running: DERP (elapsed: 100ms)")
302 })
303
304 t.Run("EmptyProgress", func(t *testing.T) {
305 t.Parallel()
306
307 mClock := quartz.NewMock(t)
308 progress := healthcheck.Progress{Clock: mClock}
309 summary := progress.Summary()
310
311 // Should be empty string when nothing tracked
312 assert.Empty(t, summary)
313 })
314
315 t.Run("AllCompleted", func(t *testing.T) {
316 t.Parallel()
317
318 mClock := quartz.NewMock(t)
319 progress := healthcheck.Progress{Clock: mClock}
320 progress.Start("Database")
321 progress.Start("DERP")
322 mClock.Advance(50 * time.Millisecond)
323 progress.Complete("Database")
324 progress.Complete("DERP")
325
326 summary := progress.Summary()
327 assert.Equal(t, summary, "Completed: DERP (50ms), Database (50ms)")
328 })
329
330 t.Run("AllRunning", func(t *testing.T) {
331 t.Parallel()
332
333 mClock := quartz.NewMock(t)
334 progress := healthcheck.Progress{Clock: mClock}

Callers

nothing calls this directly

Calls 6

StartMethod · 0.95
CompleteMethod · 0.95
SummaryMethod · 0.95
RunMethod · 0.65
EqualMethod · 0.45
EmptyMethod · 0.45

Tested by

no test coverage detected