@@ -1123,34 +1123,20 @@ class ParseFileTests: XCTestCase { // swiftlint:disable:this type_body_length
11231123 XCTAssertEqual ( fetchedFile. url, response. url)
11241124 XCTAssertNotNil ( fetchedFile. localURL)
11251125
1126- // Cache policy flakey on older Swift versions
1127- #if compiler(>=5.5.0)
11281126 // Remove URL mocker so we can check cache
11291127 MockURLProtocol . removeAll ( )
1130-
1131- let fetchedFile2 = try parseFile. fetch ( options: [ . cachePolicy( . returnCacheDataDontLoad) ] )
1132- XCTAssertEqual ( fetchedFile2. name, fetchedFile. name)
1133- XCTAssertEqual ( fetchedFile2. url, fetchedFile. url)
1134- XCTAssertNotNil ( fetchedFile2. localURL)
1135-
1136- // More cache tests
1137- guard let currentMemoryUsage = URLSession . parse. configuration. urlCache? . currentMemoryUsage,
1138- let currentDiskUsage = URLSession . parse. configuration. urlCache? . currentDiskUsage else {
1139- XCTFail ( " Should have unwrapped " )
1140- return
1141- }
1142- XCTAssertGreaterThan ( currentMemoryUsage, 0 )
1143- XCTAssertGreaterThan ( currentDiskUsage, 0 )
1144- ParseSwift . clearCache ( )
1145- guard let updatedMemoryUsage = URLSession . parse. configuration. urlCache? . currentMemoryUsage else {
1146- XCTFail ( " Should have unwrapped " )
1147- return
1128+ do {
1129+ _ = try parseFile. fetch ( options: [ . cachePolicy( . returnCacheDataDontLoad) ] )
1130+ } catch {
1131+ guard let parseError = error as? ParseError else {
1132+ XCTFail ( " Should have casted " )
1133+ return
1134+ }
1135+ XCTAssertTrue ( parseError. message. contains ( " No response " ) )
11481136 }
1149- XCTAssertLessThan ( updatedMemoryUsage, currentMemoryUsage)
1150- #endif
11511137 }
11521138
1153- func testFetchFileWithDirInName ( ) throws {
1139+ func testFetchFileWithDirectoryInName ( ) throws {
11541140 // swiftlint:disable:next line_length
11551141 guard let parseFileURL = URL ( string: " http://localhost:1337/1/files/applicationId/d3a37aed0672a024595b766f97133615_logo.svg " ) else {
11561142 XCTFail ( " Should create URL " )
@@ -1181,31 +1167,17 @@ class ParseFileTests: XCTestCase { // swiftlint:disable:this type_body_length
11811167 }
11821168 XCTAssertFalse ( localURL. pathComponents. contains ( " myFolder " ) )
11831169
1184- // Cache policy flakey on older Swift versions
1185- #if compiler(>=5.5.0)
11861170 // Remove URL mocker so we can check cache
11871171 MockURLProtocol . removeAll ( )
1188-
1189- let fetchedFile2 = try parseFile. fetch ( options: [ . cachePolicy( . returnCacheDataDontLoad) ] )
1190- XCTAssertEqual ( fetchedFile2. name, fetchedFile. name)
1191- XCTAssertEqual ( fetchedFile2. url, fetchedFile. url)
1192- XCTAssertNotNil ( fetchedFile2. localURL)
1193-
1194- // More cache tests
1195- guard let currentMemoryUsage = URLSession . parse. configuration. urlCache? . currentMemoryUsage,
1196- let currentDiskUsage = URLSession . parse. configuration. urlCache? . currentDiskUsage else {
1197- XCTFail ( " Should have unwrapped " )
1198- return
1199- }
1200- XCTAssertGreaterThan ( currentMemoryUsage, 0 )
1201- XCTAssertGreaterThan ( currentDiskUsage, 0 )
1202- ParseSwift . clearCache ( )
1203- guard let updatedMemoryUsage = URLSession . parse. configuration. urlCache? . currentMemoryUsage else {
1204- XCTFail ( " Should have unwrapped " )
1205- return
1172+ do {
1173+ _ = try parseFile. fetch ( options: [ . cachePolicy( . returnCacheDataDontLoad) ] )
1174+ } catch {
1175+ guard let parseError = error as? ParseError else {
1176+ XCTFail ( " Should have casted " )
1177+ return
1178+ }
1179+ XCTAssertTrue ( parseError. message. contains ( " No response " ) )
12061180 }
1207- XCTAssertLessThan ( updatedMemoryUsage, currentMemoryUsage)
1208- #endif
12091181 }
12101182
12111183 func testFetchFileProgress( ) throws {
0 commit comments