-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Unit Tests - Checking the background queue #777
Unit Tests - Checking the background queue #777
Conversation
MagicalRecordStack *currentStack = self.stack; | ||
|
||
[currentStack saveWithBlockAndWait:^(NSManagedObjectContext *localContext) { | ||
expect([NSThread currentThread]).toNot.equal([NSThread mainThread]); |
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.
This expectation will fail, it doesn't match with the documentation:
@param block Make changes to CoreData objects in this block using the passed in localContext. The block will be performed on a background queue, and once complete, the context will be saved.
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.
So if the documentation is wrong, please submit a PR to update the documentation. Providing this failing test proves that your understanding is correct, but merging this will break the build.
The block itself is not guaranteed to run on any particular thread — it might run on the main queue if it's a context using main queue concurrency type. Remember, context concurrency types are backed by GCD and GCD doesn't guarantee that things will always run on a specific thread (although in this instance, it usually will). The documentation needs to be updated to match Apple's description of what |
👍 I will update the documentation to match with the expected behaviour and I will remove the failing test |
Unit Tests - Checking the background queue
The documentation of
saveWithBlockAndWait:
described the block will be performed on a background queue, and once complete, the context will be saved.