test: Error when saving outcomes related to multiple tasks #725
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.
Fixes a bug when attempting to save multiple outcomes that are related to different taskUUID's. In the case of this type of save, an error is thrown since there's a verification of the taskUUIDs already being in the store.
This seems to be fixed in #727, but the test case in this PR is slightly more specific on testing the issue, let me know if you want me to close the PR.
fetchObjects
is called here:CareKit/CareKitStore/CareKitStore/CoreData/OCKStore+Outcomes.swift
Lines 150 to 151 in b16d15c
and the error happens here:
CareKit/CareKitStore/CareKitStore/CoreData/OCKStore+Outcomes.swift
Lines 164 to 170 in b16d15c
The grouping of taskID's handles the issue of multiple tasks being fetched.
This method looks like it's only being used by OCKOutcome, all others only require a fetch of one object, so they use
fetchObject
instead offetchObjects
.The workaround is the developer will need to group OCKOutcome's by taskUUID and then manually save each group instead of trying to save all at once.
You can verify by running the unit test I added against the code before the commit.