Skip to content

Increase notification health adapter coverage for HealthServer.Start - #503

Draft
Anthony-Bible with Copilot wants to merge 3 commits into
masterfrom
copilot/analyze-test-coverage
Draft

Increase notification health adapter coverage for HealthServer.Start#503
Anthony-Bible with Copilot wants to merge 3 commits into
masterfrom
copilot/analyze-test-coverage

Conversation

Copilot AI commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This PR closes a meaningful coverage gap in the notification HTTP health adapter by adding missing lifecycle tests around server startup and shutdown behavior. The previous suite validated /healthz responses but did not exercise HealthServer.Start.

  • Coverage gap addressed (Start lifecycle)

    • Adds a test for invalid bind address to assert Start surfaces listener startup errors.
    • Adds a test that starts a real ephemeral listener, confirms readiness, then cancels context and asserts graceful return.
  • Behavioral surface now covered

    • Startup failure path (bad address).
    • Runtime shutdown path (context cancellation while serving).
    • Existing handler behavior remains covered (200 ok, 503 queue connection closed, 405 for non-GET).
  • Representative test pattern

    addr := mustFreeTCPAddr(t)
    srv := NewHealthServer(addr, stubQueue{alive: true})
    
    ctx, cancel := context.WithCancel(context.Background())
    errCh := make(chan error, 1)
    go func() { errCh <- srv.Start(ctx) }()
    
    // wait until /healthz is reachable, then cancel
    cancel()
    
    if err := <-errCh; err != nil {
        t.Fatalf("Start returned error after context cancel: %v", err)
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants