summaryrefslogtreecommitdiff
path: root/Magefile.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-14 10:27:29 +0300
committerPaul Buetow <paul@buetow.org>2026-04-14 10:27:29 +0300
commit74e1b8f37d318112d52e5a80f0f589f1b0cc7f34 (patch)
treec8dbdd3740b6e9f7f14620f549decafcefae5a02 /Magefile.go
parent254426152804be2a439a071d17478976089d2643 (diff)
test: microservice coverage for task 63
Add table-driven HTTP and unit tests for report (all formats, negatives), upload/auth boundaries, upload helpers, readiness, Run and logging. Extend authkeys tests for Close, CreateKey validation, and post-close errors. Add CLI tests for defaultListenFromEnv and create-client-key with -auth-db only. Add mage CoverMicroservice for local/CI-style coverage measurement. Use context.Background and os.Chdir for Go 1.21-compatible tests. Made-with: Cursor
Diffstat (limited to 'Magefile.go')
-rw-r--r--Magefile.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/Magefile.go b/Magefile.go
index 07bfe1c..ac2f23e 100644
--- a/Magefile.go
+++ b/Magefile.go
@@ -28,6 +28,16 @@ func Test() error {
return sh.RunV("go", "test", "./...")
}
+// CoverMicroservice runs tests with coverage for daemon, authkeys, and cli, then prints per-function coverage (go tool cover -func).
+func CoverMicroservice() error {
+ profile := filepath.Join(os.TempDir(), "goprecords-microservice.cover")
+ if err := sh.RunV("go", "test", "-coverprofile", profile, "-covermode", "count",
+ "./internal/daemon/...", "./internal/authkeys/...", "./internal/cli/..."); err != nil {
+ return err
+ }
+ return sh.RunV("go", "tool", "cover", "-func", profile)
+}
+
// Install builds and installs the binary to GOPATH/bin.
func Install() error {
mg.Deps(Build)