Add unit tests for CloudSync backup/restore#29
Merged
Conversation
Tests the CloudSync orchestration with an injected CloudProvider and a mocked db, using real Encryption + gzip for a genuine backup->restore round-trip: verifies the encrypted/compressed payload round-trips back to the original database bytes, pre-backup authentication, upload-failure wrapping, missing-backup and wrong-password errors, auto-sync start/stop, and SDK-readiness delegation. Also covers GoogleDriveProvider basics (construction, token-based auth state, initial SDK readiness). cloudSync.ts goes from ~1% to ~23%; the GoogleDriveProvider fetch/GIS internals remain for a follow-up. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests
src/lib/cloudSync.ts(~1035 lines, was ~1%), taking it to ~23% by covering theCloudSyncorchestration class andGoogleDriveProviderbasics.Approach
CloudSync.backup/restoretake an injectableCloudProvider, so the test uses a fake provider that stores the uploaded blob and returns it on download — with realEncryption+ gzip — for a genuine round-trip.Coverage
GZ1:prefix), restore decrypts+decompresses back to the exact original database bytes →db.importDatabase.Failed to upload backupwrapping, missing-backup error, wrong-password →Incorrect password,startAutoSync/stopAutoSync, and SDK-readiness delegation.isAuthenticated, and initialisWebSdkReady.The remaining ~77% is
GoogleDriveProvider's auth/upload/download/refresh — Google Drive REST + GIS SDK +CapacitorHttpglue that needs heavyfetch/SDK mocking; a good follow-up.Testing
npm run lint,type-check, andvitest runpass (Node 22). Full suite: 288 tests across 31 files.🤖 Generated with Claude Code