Skip to content

test: add end-to-end suite against a real tenant#47

Draft
piotrek-janus wants to merge 1 commit into
masterfrom
glowing-partridge
Draft

test: add end-to-end suite against a real tenant#47
piotrek-janus wants to merge 1 commit into
masterfrom
glowing-partridge

Conversation

@piotrek-janus

Copy link
Copy Markdown
Contributor

What

Adds a real-server end-to-end suite (e2e/, build-tagged //go:build e2e) that drives the compiled cac binary as a subprocess against the postmance-dev test tenant. It targets the tool↔API contract — the class of bug a hand-written mock can't catch.

Two tests:

  • TestImportAndPull — create a workspace via push --method import, pull it back, assert the server file is written with the expected name.
  • TestImportRoundTrip (core contract test) — change the workspace name locally, re-import, pull into a fresh dir, assert the change persisted remotely.

How it runs

  • make test-e2e locally, or go test -tags e2e ./e2e/.... The default go test ./internal/... is unaffected (build tag).
  • Credentials via CAC_E2E_* env vars — a gitignored .env.local locally (see .env.local.example), repo secrets in CI.
  • CI: .github/workflows/e2e.yaml runs on merge_group so it executes once on the to-be-merged HEAD; intended as a required check via merge queue.

Tenant constraints handled (discovered via live testing)

  • Workspaces are created via import — the e2e client lacks server-admin rights for the admin API.
  • Mutations use import, not patch — the rfc7396 patch endpoint is request_forbidden for this client.
  • The config API rate-limits bursts with request_forbidden; runCAC retries with backoff and tests run sequentially.

Known limitations / follow-ups

  • Workspace deletion is not implemented — runs leak e2e-* workspaces (cleanup to be designed separately).
  • Raising the e2e client's config-API rate limit would speed up runs.
  • Before this gates merges: enable merge queue on master and mark the e2e job a required check; add the CAC_E2E_* secrets to the e2e environment.

Design notes: docs/superpowers/specs/2026-06-25-cac-e2e-tests-design.md.

Adds a build-tagged (//go:build e2e) suite under e2e/ that runs the compiled
cac binary as a subprocess against the postmance-dev test tenant:

- TestImportAndPull: create a workspace via `push --method import`, pull it back
- TestImportRoundTrip: change the workspace name, re-import, pull into a fresh
  dir, and assert the change persisted (the contract assertion a mock can't make)

Tenant constraints handled: workspaces are created via import (the client lacks
server-admin rights), mutations use import (the rfc7396 patch endpoint is
forbidden for this client), and runCAC retries the config API's burst
rate-limit (request_forbidden) with backoff. Tests run sequentially.

Credentials come from CAC_E2E_* env vars (gitignored .env.local locally, secrets
in CI); .env.local.example documents them. CI runs on merge_group via
.github/workflows/e2e.yaml. Env parsing uses subosito/gotenv (already in the
module graph via viper).

Workspace deletion is not yet implemented; runs leak e2e-* workspaces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant