Hi, my team wants to use pact in or microservice d...
# pact-swift
d
Hi, my team wants to use pact in or microservice deployment. We have a few vapor/swift services. And I was tasked to research if we can use pact. And I am struggling a bit 🙈. The pact files do not seem to appear on my machine. This is the code, I am using an async function, which is the only difference I can see from the examples. I tried to change the directory to one that does not exist and then I get an error that it could not write the file. But when I create that directory it is silence again and my test succeeds. Thank you very much in advanced 🙏.
Copy code
var mockService: MockService!
    var app: Application!

    override func setUp() async throws {
        mockService = MockService(consumer: "payments", provider: "coexp")
        app = Application(.testing)
    }

    func test_create_session() {
        mockService
            .uponReceiving("Create a card session request")
            .withRequest(method: .POST, path: "/session")
            .willRespondWith(status: 200, headers: nil, body: [
                "session_key": ExampleGenerator.RandomUUID(),
                "terminal_id": ExampleGenerator.RandomUUID(),
            ])
        mockService.run(timeout: 5000) { baseURL, done in
            let terminal = TerminalService.live(baseUrl: baseURL)
            Task {
                let result = try await terminal.getSessionKey(self.app.http.client.shared)
                
                switch result {
                case  .success(_) :
                    XCTPass()
                case .failure(_):
                    XCTFail()
                }
                done()
            }
            
        }
    }
m
What example(s) have you followed setting up your environment?
m
And have you tried passing the directory URL to the MockService initialiser?
d
Yes, I did but must have made a typo or something. Now it works. wonderful thank you for the help 🙂
👍 1