-
Notifications
You must be signed in to change notification settings - Fork 63
Make SyncEngine more testable #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mbrandonw
wants to merge
15
commits into
main
Choose a base branch
from
testable-sync-engine
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
12d24fb
Improvements to testability of SyncEngine.
mbrandonw e2ef097
Merge remote-tracking branch 'origin/main' into testable-sync-engine
mbrandonw 726848f
wip
mbrandonw ecc9dc0
wip
mbrandonw e549af8
wip
mbrandonw 8875087
simplify
mbrandonw 032988a
more simplify
mbrandonw 42944ee
wip
mbrandonw 2ab4df1
clean up
mbrandonw c89ffe8
wip
mbrandonw 76b33ea
wip
mbrandonw 6b8a041
wip
mbrandonw 8ac8f10
wip
mbrandonw ee21e04
Merge remote-tracking branch 'origin/main' into testable-sync-engine
mbrandonw 213a68e
wip
mbrandonw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| import Dependencies | ||
| import DependenciesTestSupport | ||
| import Foundation | ||
| import InlineSnapshotTesting | ||
| import SnapshotTestingCustomDump | ||
| import Testing | ||
|
|
@@ -8,6 +10,9 @@ import Testing | |
| extension BaseTestSuite { | ||
| @MainActor | ||
| struct RemindersListsTests { | ||
| @Dependency(\.defaultDatabase) var database | ||
| @Dependency(\.defaultSyncEngine) var syncEngine | ||
|
|
||
| @Test func basics() async throws { | ||
| let model = RemindersListsModel() | ||
| try await model.$remindersLists.load() | ||
|
|
@@ -100,5 +105,54 @@ extension BaseTestSuite { | |
| """ | ||
| } | ||
| } | ||
|
|
||
| @Test func share() async throws { | ||
| let model = RemindersListsModel() | ||
|
|
||
| let personalRemindersList = try #require( | ||
| try await database.read { db in | ||
| try RemindersList.find(UUID(0)).fetchOne(db) | ||
| } | ||
| ) | ||
| let _ = try await syncEngine.share(record: personalRemindersList, configure: { _ in }) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't a ton we can test in our demo when it comes to sharing, but we can at least see that the act of sharing this list does indeed populate the |
||
|
|
||
| try await model.$remindersLists.load() | ||
| assertInlineSnapshot(of: model.remindersLists, as: .customDump) { | ||
| """ | ||
| [ | ||
| [0]: RemindersListsModel.ReminderListState( | ||
| remindersCount: 4, | ||
| remindersList: RemindersList( | ||
| id: UUID(00000000-0000-0000-0000-000000000000), | ||
| color: 1218047999, | ||
| position: 1, | ||
| title: "Personal" | ||
| ), | ||
| share: CKShare() | ||
| ), | ||
| [1]: RemindersListsModel.ReminderListState( | ||
| remindersCount: 2, | ||
| remindersList: RemindersList( | ||
| id: UUID(00000000-0000-0000-0000-000000000001), | ||
| color: 3985191935, | ||
| position: 2, | ||
| title: "Family" | ||
| ), | ||
| share: nil | ||
| ), | ||
| [2]: RemindersListsModel.ReminderListState( | ||
| remindersCount: 2, | ||
| remindersList: RemindersList( | ||
| id: UUID(00000000-0000-0000-0000-000000000002), | ||
| color: 2992493567, | ||
| position: 3, | ||
| title: "Business" | ||
| ), | ||
| share: nil | ||
| ) | ||
| ] | ||
| """ | ||
| } | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now users of our library can decide to send all changes to "iCloud" after they bootstrap their database (in reality this sends the records to a completely mocked, in-memory version of iCloud).