-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathFileCacheRepositoryTests.swift
43 lines (37 loc) · 1.87 KB
/
FileCacheRepositoryTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@testable import MEGA
import MEGADomain
import MEGADomainMock
import MEGASDKRepo
import XCTest
class FileCacheRepositoryTests: XCTestCase {
func testTempFileURL() throws {
let url = URL(string: "http://mega.nz")
let sut = FileCacheRepository(fileManager: MockFileManager(tempURL: url!, containerURL: url!))
let node = NodeEntity(name: "testNode", base64Handle: "testHandle")
let expectedTempFileURL = try XCTUnwrap(url?.appendingPathComponent("testHandle").appendingPathComponent("testNode"))
XCTAssertEqual(sut.tempFileURL(for: node), expectedTempFileURL)
}
func testCachedOriginalImageDirectoryURL() throws {
let url = URL(string: "http://mega.nz")
let sut = FileCacheRepository(fileManager: MockFileManager(tempURL: url!, containerURL: url!))
let expectedTempFileURL = try XCTUnwrap(
url?
.appendingPathComponent("Library/Caches", isDirectory: true)
.appendingPathComponent("originalV3", isDirectory: true)
)
XCTAssertEqual(sut.cachedOriginalImageDirectoryURL, expectedTempFileURL)
}
func testCachedOriginalImageURL() throws {
let url = URL(string: "http://mega.nz")
let sut = FileCacheRepository(fileManager: MockFileManager(tempURL: url!, containerURL: url!))
let node = NodeEntity(name: "testImage", base64Handle: "testImageHandle")
let expectedTempFileURL = try XCTUnwrap(
url?
.appendingPathComponent("Library/Caches", isDirectory: true)
.appendingPathComponent("originalV3", isDirectory: true)
.appendingPathComponent("testImageHandle", isDirectory: true)
.appendingPathComponent("testImage", isDirectory: false)
)
XCTAssertEqual(sut.cachedOriginalImageURL(for: node), expectedTempFileURL)
}
}