Skip to content
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

Merged

Conversation

fjbelchi
Copy link

The documentation of saveWithBlockAndWait: described the block will be performed on a background queue, and once complete, the context will be saved.

MagicalRecordStack *currentStack = self.stack;

[currentStack saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
expect([NSThread currentThread]).toNot.equal([NSThread mainThread]);
Copy link
Author

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.

Copy link
Contributor

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.

@tonyarnold
Copy link
Contributor

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 performBlock:, performBlockAndWait:, etc do.

@fjbelchi
Copy link
Author

👍 I will update the documentation to match with the expected behaviour and I will remove the failing test

tonyarnold added a commit that referenced this pull request May 26, 2015
Unit Tests - Checking the background queue
@tonyarnold tonyarnold merged commit e22651c into magicalpanda:release/3.0 May 26, 2015
@tonyarnold tonyarnold added this to the 3.0.0 milestone May 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants