Skip to content

Commit 2fdd5f3

Browse files
committed
test(self-update): add comprehensive unit tests for self-update command
Add complete test coverage for the refactored self-update command. Tests validate the full update flow including npm registry integration, version checking, binary replacement, and error handling. Test coverage (21 tests): - Prerequisite checks (2 tests) - SEA binary requirement - Binary path validation - Version comparison (3 tests) - Skip update when already on latest - Update when newer version available - Force update with --force flag - Dry-run mode (2 tests) - Check without downloading - Verify no file modifications - Successful update flow (7 tests) - Fetch version from npm registry - Download package tarball - Verify package integrity - Extract binary from tarball - Create backup of current binary - Set executable permissions - Clear quarantine on macOS - Error handling (3 tests) - Invalid package metadata - Integrity verification failure - Rollback on replacement failure - Stub update (2 tests) - Update when launched via bootstrap - Skip when not using bootstrap - Cleanup (2 tests) - Clean up after successful update - Clean up after failed update Test approach: - Mocks all external dependencies (npm-registry, os, env, executable detection) - Uses real filesystem operations in temp directories - Validates both success and failure paths - Tests flag behavior (--dry-run, --force)
1 parent c6d7c2f commit 2fdd5f3

File tree

1 file changed

+468
-0
lines changed

1 file changed

+468
-0
lines changed

0 commit comments

Comments
 (0)