Skip to content

Commit

Permalink
Make mock response objects public
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHLawrence committed Jan 23, 2024
1 parent 644a92e commit 2b7407c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Sources/SimpleRESTClient/MockTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import Foundation

/// Mock API response for testing.
public struct MockResponse {
let statusCode: Int
let body: Data
public let statusCode: Int
public let body: Data

init(statusCode: Int, body: Data) {
public init(statusCode: Int, body: Data) {
self.statusCode = statusCode
self.body = body
}

init?(statusCode: Int, filename: String, sourceFolder: URL) {
public init?(statusCode: Int, filename: String, sourceFolder: URL) {

let mockURL = sourceFolder
.appendingPathComponent(filename)
Expand All @@ -35,9 +35,15 @@ public struct MockResponse {

/// An expected API call and its associated response.
public struct ExpectedRequest {
let url: String
let method: String
let response: MockResponse
public let url: String
public let method: String
public let response: MockResponse

public init(url: String, method: String, response: MockResponse) {
self.url = url
self.method = method
self.response = response
}
}

/// Mock implementation of ``Transport`` for unit testing.
Expand Down

0 comments on commit 2b7407c

Please sign in to comment.