88 lines
3.4 KiB
Markdown
88 lines
3.4 KiB
Markdown
# Test Coverage Report — uopi
|
||
|
||
**Date:** 2026-06-24
|
||
**Branch:** develop
|
||
**Task:** #167 — Raise backend coverage toward 90%
|
||
**Status:** All suites green — `go test ./... -race`, `go vet ./...`, and `gofmt -l` clean.
|
||
|
||
## Overall
|
||
|
||
- **Main module total coverage: 67.7%** of statements.
|
||
- **38 test files, 218 test/bench/fuzz functions** in the main module.
|
||
- **27 new test files** added across the coverage initiative.
|
||
- 3-module `go.work` workspace — each module is tested independently (`go test ./...`
|
||
from the root only exercises the main module; `pkg/ca` and `pkg/pva` must be tested
|
||
by `cd`-ing into them).
|
||
|
||
## Main module (`github.com/uopi/uopi`) — by package
|
||
|
||
| Coverage | Package | Notes |
|
||
|---|---|---|
|
||
| 100.0% | `internal/config` | |
|
||
| 100.0% | `internal/pamauth` | stub (non-PAM build) |
|
||
| 97.1% | `internal/metrics` | |
|
||
| 96.3% | `internal/broker` | signal fan-out core |
|
||
| 89.2% | `internal/panelacl` | |
|
||
| 89.0% | `internal/audit` | |
|
||
| 85.5% | `internal/access` | |
|
||
| 82.6% | `internal/storage` | |
|
||
| 82.4% | `internal/datasource/stub` | |
|
||
| 81.7% | `internal/confmgr` | |
|
||
| 81.0% | `internal/dsp` | |
|
||
| 79.1% | `internal/datasource/servervar` | |
|
||
| 72.9% | `internal/datasource/synthetic` | |
|
||
| 67.2% | `internal/api` | large handler surface |
|
||
| 66.6% | `internal/controllogic` | engine/Lua/cron uncovered |
|
||
| 55.6% | `internal/datasource` | iface + ctx helpers |
|
||
| 34.1% | `internal/server` | HTTP/WebSocket |
|
||
| 33.9% | `internal/ldapauth` | network-bound |
|
||
| 33.6% | `internal/datasource/epics` | CGo/libca-bound |
|
||
| 0.0% | `internal/datasource/pva` | network-bound |
|
||
| 0.0% | `cmd/uopi`, `cmd/catools`, `cmd/pvtools`, `tools/buildfrontend` | mains — no tests |
|
||
|
||
## Workspace modules
|
||
|
||
| Module | Coverage |
|
||
|---|---|
|
||
| `pkg/ca` (goca) | **83.9%** root · 90.0% `proto` · `testca` 0% (test harness) |
|
||
| `pkg/pva` (gopva) | 85.5% `pvdata` · 12.1% root (network client) |
|
||
|
||
## Remaining gaps toward 90%
|
||
|
||
The lowest packages are all **I/O- or platform-bound**, needing integration harnesses
|
||
rather than unit tests:
|
||
|
||
- `server` (34%) — HTTP/WebSocket handlers.
|
||
- `ldapauth` (34%) — needs a mock LDAP server.
|
||
- `datasource/epics` (34%) — CGo `libca` linkage.
|
||
- `datasource/pva` (0%) — needs a PVA test server (analogous to `testca` for CA).
|
||
- `cmd/*` mains — typically excluded from coverage targets.
|
||
|
||
Pure-logic packages are now in the 80–100% range. The biggest realistic remaining
|
||
wins are `api` (67%) and `controllogic` (67%), where the uncovered code is the
|
||
control-logic **engine** (Lua runtime, cron scheduling, dialog emission) and the
|
||
network-dependent API handlers (channelFinder, archiverSearch).
|
||
|
||
## Coverage gains (this initiative)
|
||
|
||
| Package | Before | After |
|
||
|---|---|---|
|
||
| `internal/api` | 53.8% | 67.2% |
|
||
| `internal/audit` | 75.3% | 89.0% |
|
||
| `internal/broker` | 78.9% | 96.3% |
|
||
| `internal/panelacl` | 65.9% | 89.2% |
|
||
| `internal/confmgr` | 73.4% | 81.7% |
|
||
| `internal/dsp` | 66.3% | 81.0% |
|
||
| `internal/datasource` | 0% | 55.6% |
|
||
| `internal/pamauth` | 0% | 100% |
|
||
| `pkg/ca` | 82.2% | 83.9% |
|
||
|
||
## Notes
|
||
|
||
- Two inherently racy assertions were deliberately dropped (broker cancelled-context
|
||
`ReadNow`; audit closed-channel synchronous fallback): both depended on
|
||
nondeterministic `select` ordering and flaked under `-race`. The surrounding code
|
||
paths remain covered by other tests.
|
||
- All new test files are `gofmt`-clean, matching the CI gate
|
||
(`gofmt -l $(git ls-files '*.go')`).
|