Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
billp committed Aug 19, 2023
1 parent 0b6515c commit 61dcb56
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
11 changes: 5 additions & 6 deletions Tests/TestDownloadOperationsAsync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}

Expand Down
12 changes: 2 additions & 10 deletions Tests/TestReachability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/TestTNErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Tests/TestUploadOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions Tests/TestUploadOperationsAsync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 61dcb56

Please sign in to comment.