test(unit): cover tag selection, deployment state, and preview cleanup #519

Merged
fuzzy merged 1 commit from test/unit-tests into main 2026-08-04 08:39:42 +00:00
Owner

What

Close the unit-test gaps across three areas:

  • Tag selection (#109) — extend pkg/version/version_test.go with duplicate highest tags, leading zeros (v01.2.3), malformed suffixes (trailing dot/hyphen/plus, leading dash), and document the first-seen-wins behavior on equal versions.
  • Deployment state management (#110) — new internal/site/memory_deployments_test.go giving MemoryDeploymentRepository direct CRUD coverage (Create/Get/ListBySite newest-first/Update/Delete plus ErrNotFound paths), and a pending → building → active → failed status-transition test that also asserts Service.Status reports the latest deployment.
  • Preview cleanup (#111) — extend internal/site/service_test.go CleanupPreviews coverage: multiple sites, the no-previews case, and error propagation when the Kubernetes DeletePreview call fails.

Why

Phase 8 task #112 — the deployment repository previously had no direct test file, and tag-selection/cleanup edge cases were untested.

Testing

  • go build ./...
  • go vet ./...
  • go test -race -count=1 ./... — full suite passes
  • gofmt -l ./cmd ./internal ./pkg clean
  • golangci-lint run — 0 issues
  • pre-commit hooks all pass

Breaking Changes

None.

Notes

  • Issues #109, #110, #111, #112 closed via the Forgejo API as part of this task per the workflow.

Closes #109
Closes #110
Closes #111
Closes #112

## What Close the unit-test gaps across three areas: - **Tag selection (#109)** — extend `pkg/version/version_test.go` with duplicate highest tags, leading zeros (`v01.2.3`), malformed suffixes (trailing dot/hyphen/plus, leading dash), and document the first-seen-wins behavior on equal versions. - **Deployment state management (#110)** — new `internal/site/memory_deployments_test.go` giving `MemoryDeploymentRepository` direct CRUD coverage (Create/Get/ListBySite newest-first/Update/Delete plus `ErrNotFound` paths), and a `pending → building → active → failed` status-transition test that also asserts `Service.Status` reports the latest deployment. - **Preview cleanup (#111)** — extend `internal/site/service_test.go` `CleanupPreviews` coverage: multiple sites, the no-previews case, and error propagation when the Kubernetes `DeletePreview` call fails. ## Why Phase 8 task #112 — the deployment repository previously had no direct test file, and tag-selection/cleanup edge cases were untested. ## Testing - [x] `go build ./...` - [x] `go vet ./...` - [x] `go test -race -count=1 ./...` — full suite passes - [x] `gofmt -l ./cmd ./internal ./pkg` clean - [x] `golangci-lint run` — 0 issues - [x] pre-commit hooks all pass ## Breaking Changes None. ## Notes - Issues #109, #110, #111, #112 closed via the Forgejo API as part of this task per the workflow. Closes #109 Closes #110 Closes #111 Closes #112
test(unit): cover tag selection, deployment state, and preview cleanup
All checks were successful
Test and Release / lint (pull_request) Successful in 4m21s
Test and Release / test (pull_request) Successful in 23m14s
f88d3e628f
Close the unit-test gaps for the three sub-tasks:

- Tag selection (#109): extend pkg/version tests with duplicate highest
  tags, leading zeros, malformed suffixes (trailing dot/hyphen/plus),
  and document first-seen-wins on ties
- Deployment state management (#110): add a direct CRUD test file for
  MemoryDeploymentRepository (Create, Get, ListBySite newest-first,
  Update, Delete, ErrNotFound paths) and a pending->building->active
  ->failed status transition test that also checks Status reports the
  latest deployment
- Preview cleanup (#111): cover multiple sites, the no-previews case,
  and error propagation when Kubernetes deletion fails

Mark task done in ROADMAP.md.

closes #109
closes #110
closes #111
closes #112
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-04 08:16:54 +00:00
the.auditor left a comment

Review Summary

Verified locally on the PR head (f88d3e6): go build, go vet, gofmt, golangci-lint run all clean; full suite passes with -race -count=1 (test-only PR).

Well-targeted additions that close the previously noted gaps:

  • Tag selection — new Parse edge cases (v1.2.3., v1.2.3-, v1.2.3+, -v1.2.3 all rejected) and Highest cases (duplicate highest, leading zeros, and the documented first-seen-wins behavior for equal versions). I traced each through the implementation — all correct.
  • Deployment state — new memory_deployments_test.go gives MemoryDeploymentRepository direct CRUD coverage including ErrNotFound paths and newest-first ordering, plus a pending → building → active → failed status-transition test that verifies Service.Status reflects the latest.
  • Preview cleanupCleanupPreviews now covered for multiple sites, the no-previews case, and error propagation when the Kubernetes delete fails.

No blocking issues.

Non-blocking observation: the "status transitions" test verifies statuses round-trip through the store and surface via Status — there's no transition-order validation in the repository (it's a dumb store), so the test is documenting behavior rather than enforcing a state machine. Fine, since no such constraint exists in the code.

Approving.

## Review Summary Verified locally on the PR head (`f88d3e6`): `go build`, `go vet`, `gofmt`, `golangci-lint run` all clean; full suite passes with `-race -count=1` (test-only PR). Well-targeted additions that close the previously noted gaps: - **Tag selection** — new `Parse` edge cases (`v1.2.3.`, `v1.2.3-`, `v1.2.3+`, `-v1.2.3` all rejected) and `Highest` cases (duplicate highest, leading zeros, and the documented first-seen-wins behavior for equal versions). I traced each through the implementation — all correct. - **Deployment state** — new `memory_deployments_test.go` gives `MemoryDeploymentRepository` direct CRUD coverage including `ErrNotFound` paths and newest-first ordering, plus a `pending → building → active → failed` status-transition test that verifies `Service.Status` reflects the latest. - **Preview cleanup** — `CleanupPreviews` now covered for multiple sites, the no-previews case, and error propagation when the Kubernetes delete fails. **No blocking issues.** Non-blocking observation: the "status transitions" test verifies statuses round-trip through the store and surface via `Status` — there's no transition-order validation in the repository (it's a dumb store), so the test is documenting behavior rather than enforcing a state machine. Fine, since no such constraint exists in the code. Approving.
fuzzy merged commit f88d3e628f into main 2026-08-04 08:39:42 +00:00
fuzzy deleted branch test/unit-tests 2026-08-04 08:39:42 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!519
No description provided.