Skip to content

Commit 16dd9d9

Browse files
committed
fix: Tests.
Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
1 parent 44bd143 commit 16dd9d9

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

Tests/Interface/MockRemoteInterface.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,9 @@ public class MockRemoteInterface: RemoteInterface {
997997
fileNameLocalPath: String,
998998
account: String,
999999
options _: NKRequestOptions,
1000-
requestHandler _: @escaping (_ request: DownloadRequest) -> Void,
1001-
taskHandler _: @escaping (_ task: URLSessionTask) -> Void,
1002-
progressHandler _: @escaping (_ progress: Progress) -> Void
1000+
requestHandler _: @escaping (_ request: DownloadRequest) -> Void = { _ in },
1001+
taskHandler _: @escaping (_ task: URLSessionTask) -> Void = { _ in },
1002+
progressHandler _: @escaping (_ progress: Progress) -> Void = { _ in }
10031003
) async -> (
10041004
account: String,
10051005
etag: String?,

Tests/InterfaceTests/MockRemoteInterfaceTests.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,24 +383,31 @@ final class MockRemoteInterfaceTests: XCTestCase {
383383

384384
func testDownload() async throws {
385385
let remoteInterface = MockRemoteInterface(rootItem: rootItem)
386+
remoteInterface.injectMock(Self.account)
387+
386388
debugPrint(remoteInterface)
387-
let fileUrl = FileManager.default.temporaryDirectory.appendingPathComponent(
388-
"file.txt", conformingTo: .text
389-
)
389+
390+
let fileUrl = FileManager.default.temporaryDirectory.appendingPathComponent("file.txt", conformingTo: .text)
391+
390392
if !FileManager.default.isWritableFile(atPath: fileUrl.path) {
391393
print("WARNING: TEMP NOT WRITEABLE. SKIPPING TEST")
392394
return
393395
}
396+
394397
let fileData = Data("Hello, World!".utf8)
395398
_ = await remoteInterface.upload(
396-
remotePath: Self.account.davFilesUrl + "/file.txt", localPath: fileUrl.path, account: Self.account
397-
)
398-
399-
let result = await remoteInterface.download(
400399
remotePath: Self.account.davFilesUrl + "/file.txt",
401400
localPath: fileUrl.path,
402401
account: Self.account
403402
)
403+
404+
let result = await remoteInterface.downloadAsync(
405+
serverUrlFileName: Self.account.davFilesUrl + "/file.txt",
406+
fileNameLocalPath: fileUrl.path,
407+
account: Self.account.ncKitAccount,
408+
options: .init()
409+
)
410+
404411
XCTAssertEqual(result.nkError, .success)
405412

406413
let downloadedData = try Data(contentsOf: fileUrl)
@@ -859,3 +866,4 @@ final class MockRemoteInterfaceTests: XCTestCase {
859866
XCTAssertEqual(failState, .authenticationError)
860867
}
861868
}
869+

0 commit comments

Comments
 (0)