test(coverage): worker internal/jobs 89.3% → ≥95%#57
Merged
Conversation
Closes the internal/jobs coverage gap to well above the 95% floor, measured by full-suite go test ./... (not a -run filter). Source seams (no behaviour change): - k8sNamespaceClient / k8sPodStateClient / k8sDeployStatusClient / k8sAutopsyClient fields retyped *kubernetes.Clientset → kubernetes.Interface so fake.NewSimpleClientset can drive every method (the long-standing follow-up noted in deploy_lifecycle_coverage_test.go). NewK8sAutopsyClient + buildDeployStatusAndAutopsy take the interface too. - custom_domain_reconcile.go: txtLookupFunc package seam for hermetic TXT-resolution tests. New tests: - k8s_clients_fake_coverage_test.go — every namespace/pod-state/deploy-status/ autopsy method incl. IsNotFound idempotency + generic-error reactor arms, plus the dual-failure-or-success constructors. - github_deploy_dispatcher_work_coverage_test.go — Work/claimBatch/dispatch/ postRedeploy/markFailed/markCompleted/permanentError across happy + every error branch (sqlmock + httptest + custom RoundTrippers). - custom_domain_reconcile_coverage_test.go — all Work switch arms, every reconcile result, all SQL helpers, TXT match/miss/error. - workers_schedule_coverage_test.go — cron PeriodicSchedule.Next impls, Started, entitlementRegraderAdapter, StartWorkers bad-DSN guard + a full River boot (TEST_WORKER_STARTUP_DSN) covering all of StartWorkers + Stop's drain arm. go build / go vet / make gate clean; full suite green under -race. 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.
Summary
Closes the
internal/jobscode-coverage gap. Measured by full-suitego test ./...(not a per-file-runfilter, which overstates coverage), the package goes from 89.7% → 96.5%, clearing the ≥95% floor with margin. Seams, not waivers.Coverage block
internal/jobsaggregate (full-suite)Per-file (the files this PR touches), aggregate statement coverage:
k8s_namespace_client.gocustom_domain_reconcile.gogithub_deploy_dispatcher.goworkers.godeploy_status_reconcile.godeploy_failure_autopsy.go(Per-file numbers can sit below 95% while the package aggregate — the gate — is 96.5%; the residual per-file misses are live-S3 / live-k8s success returns and template-
Execute-after-Mustdegraded arms.)What changed
Source seams (no behaviour change)
k8sNamespaceClient,k8sPodStateClient,k8sDeployStatusClient,k8sAutopsyClient) had theircsfield retyped from the concrete*kubernetes.Clientsetto thekubernetes.Interfacesofake.NewSimpleClientsetcan stand in. This is the exact follow-up the existingdeploy_lifecycle_coverage_test.gonote asked for.NewK8sAutopsyClient+ newbuildDeployStatusAndAutopsytake the interface too.custom_domain_reconcile.go: added atxtLookupFuncpackage-level seam so the TXT match/miss/error arms are hermetically testable.New test files
k8s_clients_fake_coverage_test.go— every namespace / pod-state / deploy-status / autopsy method against a fake clientset, including theapierrors.IsNotFoundidempotency arms and the generic-error arms (fake reactor), plus the dual-failure-or-success constructors.github_deploy_dispatcher_work_coverage_test.go—Work/claimBatch/dispatch/postRedeploy/markFailed/markCompleted/permanentError.Erroracross happy path and every error branch (sqlmock + httptest + customRoundTrippers).custom_domain_reconcile_coverage_test.go— allWorkswitch arms, everyreconcileResult, all SQL helpers, TXT variants.workers_schedule_coverage_test.go— the three cronPeriodicSchedule.Nextimpls +scheduleFunc.Next,Workers.Started,entitlementRegraderAdapter, theStartWorkersbad-DSN guard, and a full River boot ofStartWorkers(gated on a dedicatedTEST_WORKER_STARTUP_DSNso it never perturbs the api-schemaTEST_DATABASE_URLthe propagation integration tests use) that covers the entireStartWorkersbody +Workers.Stop's graceful-drain arm.Verification
go build ./...cleango vet ./...cleanmake gategreen (the CI-equivalent-shortgate; the new DB-driven test skips cleanly with noTEST_*env, exactly as CI runs)-race(no data races)Functions still <95% (and why)
All residual are the un-seam-able tail:
backup_s3.go/platform_db_backup_s3.goUpload/Download/Deletesuccess returns (need a live S3/MinIO — error arms are covered),lifecycle_emails.gorenderShell/renderBody/lifecycleTextdegraded fallbacks (unreachable aftertemplate.Must),real_prober.golive-probe success tails, andworkers.goStartWorkers(80.8% — the optional-dependencyif-set branches that only fire when Razorpay/MinIO/object-store env is wired). None drag the aggregate below 95%.🤖 Generated with Claude Code