You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+29-2Lines changed: 29 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,40 @@ Use Go 1.24+ and PostgreSQL.
17
17
18
18
```bash
19
19
go mod tidy
20
-
gotest ./...
20
+
make test-unit
21
21
go vet ./...
22
22
```
23
23
24
24
Dependencies are managed through normal Go module resolution. Review dependency changes in `go.mod` and `go.sum`; the repository does not commit a `vendor/` tree.
25
25
26
-
DB-backed integration tests skip when no Postgres connection is configured. To run them, provide libpq environment variables or `READINESS_TEST_DSN`. Tests create throwaway schemas and drop them during cleanup.
26
+
DB-backed integration tests are explicit. They skip unless `HEALTH_DB_TESTS=1` is set, even when `PGHOST` or other libpq variables are present in your shell. To run them, provide libpq environment variables or `READINESS_TEST_DSN`, then use:
27
+
28
+
```bash
29
+
HEALTH_DB_TESTS=1 make test-db-storage
30
+
HEALTH_DB_TESTS=1 make test-db-ui
31
+
HEALTH_DB_TESTS=1 make test-db-ui-fast
32
+
HEALTH_DB_TESTS=1 make test-db-energy
33
+
HEALTH_DB_TESTS=1 make test-db-energy-smoke
34
+
HEALTH_DB_TESTS=1 make test-db-readiness
35
+
HEALTH_DB_TESTS=1 make test-db
36
+
```
37
+
38
+
`test-db` is the routine DB contract aggregate: fast UI DB smoke, EnergyBank DB smoke, and targeted Readiness DB checks. It intentionally does not run the full UI package, full EnergyBank verdict-band suite, or full `./internal/storage` package. Use the full domain lanes when a change touches that area.
39
+
40
+
Lane commands:
41
+
42
+
```bash
43
+
make test-db # routine DB contract: ui-fast + energy-smoke + readiness
44
+
make test-db-ui-fast # representative UI/admin DB handler checks
45
+
make test-db-energy-smoke # one EnergyBank verdict-band DB contract check
46
+
make test-db-readiness # readiness schema/calibration DB checks
47
+
make test-db-ui # full internal/ui DB package sweep
48
+
make test-db-energy # full EnergyBank verdict-band DB group
49
+
make test-db-storage # full internal/storage DB package sweep
50
+
```
51
+
52
+
When `HEALTH_DB_TESTS=1` is set, missing or unreachable Postgres is a test failure, not a skip. Tests create throwaway schemas with test prefixes and drop them during cleanup.
53
+
Readiness monitoring and broad readiness writer families are intentionally outside the routine `test-db-readiness` lane until their fixtures are narrowed or runtime is measured separately. Full UI, full Energy, and full Storage lanes are manual/domain sweeps, not the normal edit-loop.
27
54
28
55
See `docs/TEST_COVERAGE.md` for the current focused coverage roadmap and fixture rules.
Copy file name to clipboardExpand all lines: Makefile
+27-1Lines changed: 27 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
.PHONY: dev build backfill backfill-force energy-backfill energy-backfill-dry import docker-up docker-down test
1
+
.PHONY: dev build backfill backfill-force energy-backfill energy-backfill-dry import docker-up docker-down test test-unit test-db-storage test-db-ui test-db-ui-fast test-db-energy test-db-energy-smoke test-db-readiness test-db smoke-health-post
2
2
3
3
ADDR ?= :8080
4
4
@@ -40,7 +40,33 @@ docker-up:
40
40
docker-down:
41
41
docker compose down
42
42
43
+
test-unit:
44
+
HEALTH_DB_TESTS= CGO_ENABLED=0 go test ./...
45
+
46
+
test-db-storage:
47
+
HEALTH_DB_TESTS=1 go test ./internal/storage -count=1 -timeout=120s
48
+
49
+
test-db-ui:
50
+
HEALTH_DB_TESTS=1 go test ./internal/ui -count=1 -timeout=120s
51
+
52
+
test-db-ui-fast:
53
+
HEALTH_DB_TESTS=1 go test ./internal/ui -run "^(TestAdminCheckinCoverage_JSONShape|TestOnboardingWizard_RejectsSchemaAll|TestFragmentAdminReadinessMonitoring_Renders)$$" -count=1 -timeout=60s
54
+
55
+
test-db-energy:
56
+
HEALTH_DB_TESTS=1 go test ./internal/storage -run "TestComputeUserVerdictBands" -count=1 -timeout=90s
57
+
58
+
test-db-energy-smoke:
59
+
HEALTH_DB_TESTS=1 go test ./internal/storage -run "^TestComputeUserVerdictBands_UsesCompatibleFormulaWarmup$$" -count=1 -timeout=30s
60
+
61
+
test-db-readiness:
62
+
HEALTH_DB_TESTS=1 go test ./internal/storage -run '^(TestSaveNaiveBaseline_NilValueWithValidReasonPersists|TestVerifyReadinessRedesignSchema_DetectsReasonColumnDrift|TestRecomputeChipCalibrations_Integration_(RejectsCrossEpochLabels|PercentileP80|InsufficientData))$$' -count=1 -timeout=90s
Copy file name to clipboardExpand all lines: docs/TEST_COVERAGE.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,24 @@ This roadmap tracks high-value Health Dashboard test coverage without turning th
4
4
5
5
## Constraints
6
6
7
-
- Default CI must stay pure and fast under `go test ./...`.
7
+
- Default CI must stay pure and fast under `make test-unit` / `go test ./...`.
8
8
- Fixtures must be synthetic or anonymized. Do not commit personal health exports, screenshots, logs, or raw metric dumps.
9
-
- DB-backed tests should skip cleanly unless a Postgres connection is configured.
9
+
- DB-backed tests should skip cleanly unless `HEALTH_DB_TESTS=1` is set. When that flag is set, missing or unreachable Postgres is a failure.
10
10
- Coverage thresholds are intentionally deferred until the active product contracts have a useful baseline.
11
11
12
+
## Test Lanes
13
+
14
+
| Lane | Command | Contract |
15
+
|---|---|---|
16
+
| Unit/default |`make test-unit`| Fast pure suite. DB tests skip even if libpq env vars are present. |
17
+
| Routine DB |`HEALTH_DB_TESTS=1 make test-db`| Fast sequential DB contract aggregate: UI smoke, Energy smoke, and targeted Readiness DB checks. This is the normal DB edit-loop. |
18
+
| UI DB smoke |`HEALTH_DB_TESTS=1 make test-db-ui-fast`| Representative UI/admin DB handler checks. |
19
+
| Energy DB smoke |`HEALTH_DB_TESTS=1 make test-db-energy-smoke`| One EnergyBank verdict-band DB contract check. |
20
+
| Readiness DB |`HEALTH_DB_TESTS=1 make test-db-readiness`| Runs an explicit readiness storage regex covering baseline persistence/schema drift and chip calibration recompute. Monitoring and broad readiness-adjacent writer families stay out until measured or migrated. |
21
+
| UI DB full |`HEALTH_DB_TESTS=1 make test-db-ui`| Full `./internal/ui` DB package sweep. Manual/domain verification; currently around 41s on the remote Postgres path. |
22
+
| Energy DB full |`HEALTH_DB_TESTS=1 make test-db-energy`| Full EnergyBank verdict-band DB group: `go test ./internal/storage -run "TestComputeUserVerdictBands" -count=1 -timeout=90s`. Manual/domain verification; currently around 56s after fixture narrowing. |
23
+
| Full Storage DB |`HEALTH_DB_TESTS=1 make test-db-storage`| Full `./internal/storage` DB package run. Manual/pre-merge only; not part of `make test-db`. |
24
+
12
25
## Current Coverage Map
13
26
14
27
| Area | Current state | Next useful coverage |
@@ -18,7 +31,7 @@ This roadmap tracks high-value Health Dashboard test coverage without turning th
18
31
| UI and admin APIs | Contract tests cover admin pages, auth/session behavior, webhook dispatch, dashboard sections, and tenant scope. | Pin response-shape changes before frontend code starts depending on them. |
19
32
| Storage writers | Readiness redesign, EnergyBank, sleep gates, freshness, calibration, and tenant helpers have focused tests, with DB-backed tests gated. | Prefer bug-driven storage contract tests over broad repository-level sweeps. |
20
33
| Notifications | Morning/evening report, freshness banners, smart retry, Telegram webhook, and proactive framework tests cover key behavior. | Add regression tests when notification timing or skip conditions change. |
21
-
| CI policy | Default CI runs build, vet, and pure tests; race detector is manual and documented. | Keep race detector separate from default PR checks unless the runtime cost becomes acceptable. |
34
+
| CI policy | Default CI runs build, vet, and pure tests; targeted DB lanes are explicit local/manual checks; race detector is manual and documented. | Keep race detector and DB service-container CI separate from default PR checks unless the runtime cost becomes acceptable. |
0 commit comments