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

Adjust ImageDownloaderTests to use a new instance each time #1341

Merged
merged 4 commits into from
Apr 26, 2018

Conversation

akitchen
Copy link
Contributor

Removing this statefulness (the lazy var) should make sense here; we're registering & unregistering the URLProtocol subclass in a loop while the URL loading system may be doing other work. I'm hopeful this will help with the test instabilities noted in #1327 and elsewhere.

I also noticed that the ImageDownloader's OperationQueue's maxConcurrentOperationCount was set semi-arbitrarily, so I removed it. This defaults the configuration to NSOperationQueueDefaultMaxConcurrentOperationCount. We could also consider setting it to 2.

@akitchen akitchen requested review from JThramer and 1ec5 April 26, 2018 01:28
@akitchen akitchen force-pushed the adjust-image-downloader branch from f940411 to e6ce1a5 Compare April 26, 2018 03:37
@@ -39,7 +40,7 @@ class ImageDownloaderTests: XCTestCase {
var errorReturned: Error?
let semaphore = DispatchSemaphore(value: 0)

downloader.downloadImage(with: imageURL) { (image, data, error) in
downloader?.downloadImage(with: imageURL) { (image, data, error) in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test assert that downloader is non-nil, as the other tests do below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I was being terse since this method only touches it once. Preference was for a runtime failure (nil) vs a crash (unexpected failure unwrapping).

Happy to make it consistent with the other methods before merging.

@akitchen akitchen merged commit db54488 into master Apr 26, 2018
@akitchen akitchen deleted the adjust-image-downloader branch April 26, 2018 19:36
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