Skip to content

Add end-to-end tests for publish and install commands#30

Merged
fullstackjam merged 1 commit intomainfrom
claude/e2e-publish-import-test-eUTnh
Apr 19, 2026
Merged

Add end-to-end tests for publish and install commands#30
fullstackjam merged 1 commit intomainfrom
claude/e2e-publish-import-test-eUTnh

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds comprehensive end-to-end tests for the snapshot --publish and install commands, verifying correct HTTP request behavior against a mock API server.

Why?

These tests validate critical invariants (P7) around authentication, request methods, and payload structure:

  • snapshot --publish --slug X must use PUT (not POST) with the slug in the request body
  • snapshot --publish without a slug must resolve to a PUT using a saved sync source
  • install user/slug must fetch the cloud config with proper Bearer token authentication

The tests use a mock HTTP server to capture and verify the exact requests made by the binary, ensuring the client correctly implements the API contract.

Testing

  • Added three new end-to-end tests covering publish and install workflows
  • Tests verify HTTP method, headers, request paths, and payload structure
  • Tests use isolated temporary directories and mock servers to avoid external dependencies

Notes for reviewer

The test file uses the //go:build e2e build tag to keep these integration tests separate from unit tests. The mock server infrastructure (reqLog, newMockServer) is reusable for future API contract tests. All tests properly clean up resources via t.Cleanup().

https://claude.ai/code/session_01DfSdBjWHaSGgwzkKRYoa9C

Covers three P7 invariants without requiring a real macOS environment:
- snapshot --publish --slug X sends PUT with config_slug + Bearer token
- snapshot --publish with a saved sync source resolves to PUT (update)
- install user/slug --dry-run --silent sends GET with Bearer token

Uses httptest.NewServer as the API backend; HOME and OPENBOOT_API_URL
are isolated per test so state never leaks between runs. Tag is //go:build e2e
(no vm or destructive tags) so CI can run it without a macOS VM.

https://claude.ai/code/session_01DfSdBjWHaSGgwzkKRYoa9C
@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

@github-actions github-actions bot added the tests Tests only label Apr 19, 2026
@fullstackjam fullstackjam merged commit 99fac68 into main Apr 19, 2026
9 checks passed
@fullstackjam fullstackjam deleted the claude/e2e-publish-import-test-eUTnh branch April 19, 2026 09:13
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants