From 61dcb56ac9f2d39e0d1a487873de4d7dfa77f0af Mon Sep 17 00:00:00 2001 From: Bill Panagiotopoulos Date: Sat, 19 Aug 2023 17:41:16 +0300 Subject: [PATCH] Fix errors --- Tests/TestDownloadOperationsAsync.swift | 11 +++++------ Tests/TestReachability.swift | 12 ++---------- Tests/TestTNErrors.swift | 2 +- Tests/TestUploadOperations.swift | 4 ++-- Tests/TestUploadOperationsAsync.swift | 4 ++-- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Tests/TestDownloadOperationsAsync.swift b/Tests/TestDownloadOperationsAsync.swift index 21b8162..44ead8f 100644 --- a/Tests/TestDownloadOperationsAsync.swift +++ b/Tests/TestDownloadOperationsAsync.swift @@ -80,15 +80,15 @@ class TestDownloadOperationsAsync: XCTestCase { func testFileDownloadWithoutRepository() async { var failed = true - + guard var cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first else { XCTAssert(false) return } cacheURL.appendPathComponent("testDownload") - + try? FileManager.default.removeItem(at: cacheURL) - + do { try await Request(method: .get, url: "\(Env.termiNetworkRemote.configure().stringURL)/downloads/3cwHqdwsRyuX") @@ -98,15 +98,14 @@ class TestDownloadOperationsAsync: XCTestCase { failed = false } }) - + failed = TestHelpers.sha256(url: cacheURL) != "63b54b4506e233839f55e1228b59a1fcdec7d5ff9c13073c8a1faf92e9dcc977" - } catch let error { failed = true print(error.localizedDescription) } - + XCTAssert(!failed) } diff --git a/Tests/TestReachability.swift b/Tests/TestReachability.swift index aa7bff5..04f4ba0 100644 --- a/Tests/TestReachability.swift +++ b/Tests/TestReachability.swift @@ -147,17 +147,9 @@ class TestReachability: XCTestCase { let expectation = XCTestExpectation(description: "testReachabilityWithHostFlagsWIFI") var failed = true - var flags: [SCNetworkReachabilityFlags] - -#if os(macOS) - flags = [.isDirect, .isLocalAddress] -#else - flags = [.isWWAN, .reachable] -#endif - let reachability = Reachability(hostname: "127.0.0.1") - try? reachability.monitorState { _ in - failed = !reachability.containsFlags(flags) + try? reachability.monitorState { state in + failed = state != .wifi expectation.fulfill() } diff --git a/Tests/TestTNErrors.swift b/Tests/TestTNErrors.swift index 0739b0c..d58e8f5 100644 --- a/Tests/TestTNErrors.swift +++ b/Tests/TestTNErrors.swift @@ -92,7 +92,7 @@ class TestTNErrors: XCTestCase { func testInvalidURL() { do { - try _ = Request(method: .get, url: "http://εεε.google.κωμ", headers: nil, params: nil).asRequest() + try _ = Request(method: .get, url: "", headers: nil, params: nil).asRequest() XCTAssert(false) } catch TNError.invalidURL { XCTAssert(true) diff --git a/Tests/TestUploadOperations.swift b/Tests/TestUploadOperations.swift index 39e74cd..6e151e6 100644 --- a/Tests/TestUploadOperations.swift +++ b/Tests/TestUploadOperations.swift @@ -222,9 +222,9 @@ class TestUploadOperations: XCTestCase { Request(method: .post, url: Env.termiNetworkRemote.configure().stringURL, params: [ - "file1": .url(.init(filePath: "/path/to/file.zip")), + "file1": .url(.init(string: "/path/to/file.zip")!), "file2": .data(data: Data(), filename: "test.png", contentType: "zip"), - "expiration_date": .value(value: Date.now.ISO8601Format()) + "expiration_date": .value(value: Date().description) ]) .upload { _, _, progress in debugPrint("\(progress * 100)% completed") diff --git a/Tests/TestUploadOperationsAsync.swift b/Tests/TestUploadOperationsAsync.swift index 77ce6b9..c305aad 100644 --- a/Tests/TestUploadOperationsAsync.swift +++ b/Tests/TestUploadOperationsAsync.swift @@ -264,9 +264,9 @@ class TestUploadOperationsAsync: XCTestCase { try await Request(method: .post, url: Env.termiNetworkRemote.configure().stringURL, params: [ - "file1": .url(.init(filePath: "/path/to/file.zip")), + "file1": .url(.init(string: "/path/to/file.zip")!), "file2": .data(data: Data(), filename: "test.png", contentType: "zip"), - "expiration_date": .value(value: Date.now.ISO8601Format()) + "expiration_date": .value(value: Date().description) ]) .asyncUpload(as: Data.self) { _, _, progress in debugPrint("\(progress * 100)% completed")