test(coverage): worker internal/circuit + jobs tail → ≥95% (CI-measured)#59
Merged
Merged
Conversation
Closes the last two per-module coverage gaps in the worker repo, measured
under the EXISTING coverage.yml CI environment (postgres/redis/mongo
service containers + TEST_* env) — NOT relying on TEST_WORKER_STARTUP_DSN,
which is unset in CI so its StartWorkers boot test skips there.
internal/circuit 91.8% → 100.0%
- NewBreaker: threshold<1 clamp + cooldown<=0 default arms
- State(): half_open / within-cooldown / after-cooldown-before-trial arms
- Name(): metric-label accessor
(These tests mirror the api/internal/circuit copy by the file's own
lock-step contract — apply the same additions there in a follow-up.)
internal/jobs 94.7% → 95.1%
Reachable arms covered with sqlmock + an SDK-disabled New Relic app +
pure-value calls (no live infra):
- middleware Work: nrApp != nil transaction path + txn.NoticeError arm
- event_email_mapping build{BackupFailed,RestoreSucceeded,RestoreFailed}:
the row.ResourceType != "" column-wins arm
- billing_reconciler emit{Upgrade,Cancel}Audit: fail-open err != nil arm
- checkout_reconcile emailAbandonedCheckout: non-ErrNoRows claim error arm
- provisioner_reconciler markAbandoned: UPDATE-error arm
Otherwise-unreachable json.Marshal degradation arms (writeAudit ×3,
insertPropagationAuditRow) covered by passing an unmarshalable meta map
(chan value) — no source-level seam required.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the last two per-module coverage gaps in the worker repo so EVERY package clears the 95% floor as measured by the CI coverage job (postgres/redis/mongo service containers +
TEST_*env), not just locally.Test-only change — two files, no production code touched, no
go.modchange.Coverage block
internal/circuitinternal/jobsBoth numbers were reproduced locally under the exact CI environment that
.github/workflows/coverage.ymlruns:postgres:16-alpine+redis:7-alpine+mongo:6service containers, api/worker migrations applied, and theTEST_DATABASE_URL/TEST_REDIS_URL/TEST_POSTGRES_CUSTOMERS_URL/TEST_MONGO_URI/INSTANT_API_REPOenv block — invoked with the CI'sgo test ./... -short -count=1 -p 1 -coverprofile -covermode=atomic.How the gaps were closed
internal/circuit(pure logic, no DB):NewBreaker—threshold < 1clamp +cooldown <= 0default armsState()— half_open / open-within-cooldown / open-after-cooldown-before-trial armsName()— metric-label accessorcircuit_test.godocuments that it is kept in lock-step withapi/internal/circuit/circuit_test.go; the same test additions should be mirrored there in a follow-up (out of scope for this worker-only PR).internal/jobs(sqlmock / disabled-NR-app / unmarshalable-meta — no live infra):middleware.Work—nrApp != niltransaction path +txn.NoticeError(err)error arm (driven bynewrelic.NewApplication(ConfigEnabled(false)), hermetic, no daemon/network)event_email_mapping.build{BackupFailed,RestoreSucceeded,RestoreFailed}— therow.ResourceType != ""column-wins arm (metadata-fallback else arm already covered)billing_reconciler.emit{Upgrade,Cancel}Audit— fail-openerr != nilarmcheckout_reconcile.emailAbandonedCheckout— non-ErrNoRowsclaim-row DB-error armprovisioner_reconciler.markAbandoned—UPDATE resourceserror armjson.Marshaldegradation arms (writeAudit×3,insertPropagationAuditRow) — covered by passing a meta map containing achanvalue, so no source-level seam is neededVerification
go build ./...cleango vet ./...cleango test ./internal/circuit/... ./internal/jobs/... -race— passgo test ./... -short -p 1 -coverprofile— all packages pass; project prod floor = 95.4%Functions still < 95% (with reason — all unreachable without invasive seams)
jobs.StartWorkers(3.0%) /Workers.Stop(42.9%) — need a live River client; River exposes no interface seam (documented inworkers_lifecycle_test.go). These SKIP in CI regardless.Upload/List/Delete/Download66–83%) — require a real S3-compliant server; error-wrap arms are already covered (documented inbackup_extra_test.go).NewK8s*Clientconstructors (75%) — success path needs a reachable kube-config/in-cluster config.None of these affect the per-package floor:
internal/jobsis 95.1% with them present.DO NOT MERGE without review.