Octavian Herescu
06/27/2022, 7:40 PMReason:
Missing requesterror I understand that this error can be triggered by not pointing the api client to the mock pact server. Is it possible that the server itself is not up and running? We're checking the request and it seems to be pointing to localhost, therefore presumably to the pact server.
```class PactExampleTest: XCTestCase {
static var mockService = MockService(consumer: "Our-app",
provider: "Our-orders-service",
writePactTo: URL(fileURLWithPath: "/dev/pacts/folder", isDirectory: true))
func testGetUsers() {
PactExampleTest
.mockService
.uponReceiving("A request for orders")
.given(ProviderState(description: "orders exist", params: ["id": "12345"]))
.withRequest(method: .GET, path: "/v1/orders")
.willRespondWith(
status: 200,
headers: nil,
body: ["test": "test"]
)
let apiClient = CloudApi()
let accessTokenProvider = MockAccessTokenProviderType()
apiClient.authenticatedHTTPService = AuthenticatedHTTPService(accessTokenProvider: accessTokenProvider)
PactExampleTest.mockService.run(timeout: 1000) { [unowned self] mockServiceURL, done in
//this makes sure that the apiClient will hit the correct base url (127.0.0.1:<portNumber>) that's provided by mockServiceURL
let cloudEnvironment = mockCloudEnvironment(onlineOrderingURL: mockServiceURL)
let cloudEnvironmentLoader = CloudEnvironmentLoader()
cloudEnvironmentLoader.saveCurrentEnv(cloudEnvironment)
apiClient.retrieveOnlineOrders(forID: "1234") { dict, error in
print("DICT: \(dict)")
print(error)
}
done()
}
}
}```
Marko (IttyBittyApps / pact-swift)
06/27/2022, 9:35 PMMarko (IttyBittyApps / pact-swift)
06/27/2022, 9:37 PM