Skip to content

Commit 1949153

Browse files
authored
Merge pull request #11 from MFB-Technologies-Inc/feature/improve-MockNetworkService-subclassing
Changes methods in MockNetworkService to `open`
2 parents daf000a + 138ef06 commit 1949153

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Sources/NetworkService/URLRequest+HTTPHeader.swift

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ extension URLRequest.ContentType: HTTPHeader {
3838
public var value: String { rawValue }
3939
}
4040

41+
extension Array where Element: HTTPHeader {
42+
public var asDictionary: [String: String] {
43+
var dict = [String: String]()
44+
dict.reserveCapacity(count)
45+
return reduce(into: dict) { acc, next in
46+
acc[next.key] = next.value
47+
}
48+
}
49+
}
50+
4151
/// Model for HTTP headers
4252
public protocol HTTPHeader {
4353
var key: String { get }

Sources/NetworkServiceTestHelper/MockNetworkService.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929

3030
/// Manages the output queue and returns the new value for reach iteration.
31-
private func queue() throws -> MockOutput {
31+
open func queue() throws -> MockOutput {
3232
guard outputs.count > 0 else {
3333
throw Errors.noOutputQueued
3434
}
@@ -50,7 +50,7 @@
5050
/// this
5151
/// version of `start`.
5252
/// Delay and repeat are handled here.
53-
public func start(_: URLRequest) async -> Result<Data, Failure> {
53+
open func start(_: URLRequest) async -> Result<Data, Failure> {
5454
let next: MockOutput
5555
do {
5656
next = try queue()

0 commit comments

Comments
 (0)