Fix the unit test `test31ThatMultipleRequestForSameURLFailedCallback`

This commit is contained in:
DreamPiggy 2024-02-27 14:43:04 +08:00
parent 3565eb1018
commit f761fc7e7b
2 changed files with 9 additions and 5 deletions

View File

@ -541,6 +541,8 @@
#if SD_UIKIT
UIImageOrientation orientation = image.imageOrientation;
expect(orientation).equal(UIImageOrientationUp);
#else
expect(image.sd_imageFormat).equal(SDImageFormatJPEG);
#endif
// Manual test again for Apple's API

View File

@ -825,14 +825,17 @@
[self waitForExpectations:expectations timeout:kAsyncTestTimeout * 2];
}
- (void)test31ThatMultipleRequestForSameURLFailedCallback {
// See #3493, silly bug
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"]; // Always fail url
NSMutableArray<XCTestExpectation *> *expectations = [NSMutableArray arrayWithCapacity:100];
// Create tmp file with empty contents
NSURL *dir = [[NSURL fileURLWithPath:NSTemporaryDirectory()] URLByAppendingPathComponent:NSStringFromSelector(_cmd) isDirectory: true];
[NSFileManager.defaultManager createDirectoryAtURL:dir withIntermediateDirectories:YES attributes:nil error:nil];
NSURL *url = [dir URLByAppendingPathComponent:@"file" isDirectory:NO];
[[NSData data] writeToURL:url atomically:YES]; // Always fail url (but valid)
NSMutableArray<XCTestExpectation *> *expectations = [NSMutableArray arrayWithCapacity:10];
__block void (^recursiveBlock)(int);
void (^mainBlock)(int) = ^(int i) {
if (i > 200) return;
if (i > 10) return;
NSString *desc = [NSString stringWithFormat:@"Failed url with index %d should callback error", i];
XCTestExpectation *expectation = [self expectationWithDescription:desc];
[expectations addObject:expectation];
@ -853,7 +856,6 @@
[self waitForExpectations:expectations timeout:kAsyncTestTimeout * 2];
}
#pragma mark - SDWebImageLoader
- (void)testCustomImageLoaderWorks {
XCTestExpectation *expectation = [self expectationWithDescription:@"Custom image not works"];