Fix mock CKAsset temp path in previews #392
Merged
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
Why
Preview/test CloudKit sharing with BLOB columns fails because assets are written to / (read-only).
Error
"🟣 Scorekeeper/GameFeature.swift:90: Caught error: Error Domain=NSCocoaErrorDomain Code=642 "You can't save the file "e8525bd6-4718-4db9-827b-67f72459f877" because the volume "Macintosh HD - Data" is read only." UserInfo={NSFilePath=/e8525bd6-4718-4db9-827b-67f72459f877, NSURL=e8525bd6-4718-4db9-827b-67f72459f877 -- file:///, NSUnderlyingError=0x60000111bcc0 {Error Domain=NSPOSIXErrorDomain Code=30 "Read-only file system"}}"
Steps to Reproduce
Scorekeeper/Schema.swift, add aDatacolumn toGame:"attachment" BLOB NOT NULL DEFAULT x''Game.Draft(id: UUID(1), title: "Family gin rummy", attachment: Data([0x01]))syncEngine.share(record:)).Expected Result
Sharing succeeds (or the mock sharing view appears in preview) without filesystem errors.
Actual Result
Sharing fails during
syncEngine.share(record:)with NSCocoaErrorDomain 642, and the file path is rooted at/.Notes
Datacolumn./in preview/test contexts.NSTemporaryDirectory) or allow a dependency override for asset temp directory.Testing