-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
183 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Tests/SwiftyNetworkingTests/Helpers/JsonPlaceholderInvalidUser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// JsonPlaceholderInvalidUser.swift | ||
// | ||
// | ||
// Created by Antonio Guerra on 06/08/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct JsonPlaceholderInvalidUser: Identifiable, Decodable { | ||
var id: String | ||
var name: Int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Tests/SwiftyNetworkingTests/Helpers/JsonPlaceholderUser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// JsonPlaceholderUser.swift | ||
// | ||
// | ||
// Created by Antonio Guerra on 06/08/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct JsonPlaceholderUser: Identifiable, Decodable { | ||
var id: Int | ||
var name: String | ||
} |
39 changes: 39 additions & 0 deletions
39
Tests/SwiftyNetworkingTests/Models/SwiftyNetworkingResponseTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// SwiftyNetworkingResponseTests.swift | ||
// | ||
// | ||
// Created by Antonio Guerra on 06/08/24. | ||
// | ||
|
||
@testable import SwiftyNetworking | ||
import XCTest | ||
|
||
final class SwiftyNetworkingResponseTests: XCTestCase { | ||
|
||
var delegate: SwiftyNetworkingDelegate! | ||
var client: SwiftyNetworkingClient! | ||
|
||
override func setUpWithError() throws { | ||
delegate = SwiftyNetworkingDelegate(cache: NSCache(countLimit: 1)) | ||
client = SwiftyNetworkingClient(configuration: .default, delegate: delegate) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
delegate = nil | ||
client = nil | ||
} | ||
|
||
func testDuration() async throws { | ||
let request = SwiftyNetworkingRequest( | ||
endpoint: "https://httpbin.org", | ||
path: "get", | ||
method: .get, | ||
cachePolicy: .reloadIgnoringCacheData | ||
) | ||
let response = try await client.send(request) | ||
let start = try XCTUnwrap(response.start) | ||
let end = try XCTUnwrap(response.end) | ||
let duration = try XCTUnwrap(response.duration) | ||
XCTAssertEqual(duration, end.timeIntervalSince(start)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters