Browse Source

Add test for local cache key

onevcat 4 years ago
parent
commit
34985faf5b
1 changed files with 7 additions and 0 deletions
  1. 7 0
      Tests/KingfisherTests/ImageDataProviderTests.swift

+ 7 - 0
Tests/KingfisherTests/ImageDataProviderTests.swift

@@ -86,6 +86,13 @@ class ImageDataProviderTests: XCTestCase {
         XCTAssertEqual(url5.localFileCacheKey, "\(URL.localFileCacheKeyPrefix)///private/var/containers/Bundle/Application/ABC/Kingfisher-Demo.other/images/kingfisher-1.jpg")
     }
     
+    func testLocalFileExplicitKey() {
+        let url1 = URL(string: "file:///Users/onevcat/Library/Developer/CoreSimulator/Devices/ABC/data/Containers/Bundle/Application/DEF/Kingfisher-Demo.app/images/kingfisher-1.jpg")!
+        let imageResource = ImageResource(downloadURL: url1, cacheKey: "hello")
+        let source = imageResource.convertToSource()
+        XCTAssertEqual(source.cacheKey, "hello")
+    }
+    
     func testBase64ImageDataProvider() {
         let base64String = testImageData.base64EncodedString()
         let provider = Base64ImageDataProvider(base64String: base64String, cacheKey: "123")