Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run real device -- Pactconsumer #90

Closed
vivekthambikannu opened this issue May 30, 2022 · 1 comment
Closed

Unable to run real device -- Pactconsumer #90

vivekthambikannu opened this issue May 30, 2022 · 1 comment
Labels
invalid This doesn't seem right

Comments

@vivekthambikannu
Copy link

Hi, I am using pact consumer in my project, real time device only able to run my project unable to run in simulator.
Initially I use pactswift, after facing this issue i changed pact consumer

my local ip address is = 120.138.12.180, iam getting this error
failed - Error setting up pact: The request timed out.
failed - Verification error (check build log for mismatches): The request timed out.
My code
let verificationService = PactVerificationService(url: "http://120.138.12.180/", port: 1234)
mockService = MockService(provider: "Provider", consumer: "iOS", pactVerificationService: verificationService)

func testConsumerMaintenance() {
    let apiService = ApiService()
    let urL = mockService.baseUrl
    print("localUrl",urL)
    guard let url = URL(string: "\(urL)/banner") else {
        XCTFail("Failed to prepare url!")
        return
    }
    mockService.given("an alligator exists")
                      .uponReceiving("a request for all alligators")
                      .withRequest(method:.GET, path: "/banner",headers: ["Authorization": "Bearer a.b.c"])
                      .willRespondWith(status: 200,
                                       body: userResponse)

    //Run the tests
    mockService.run(timeout: 10000) { (testComplete) -> Void in
        apiService.apiPostMethod(url: url, withHttpMethod: .GET) { (alligators) in
            XCTAssertNotNil(alligators)
            XCTAssertEqual(2, alligators?.data?[0].id)
          testComplete()
        }
      }
    }
@surpher surpher added the invalid This doesn't seem right label May 31, 2022
@surpher
Copy link
Owner

surpher commented May 31, 2022

Wrong framework. If you're using pact-consumer-swift then you should share the environment set up and what you've tried already here.

PactSwift will not work with an external Pact Mock Service. The PactSwift.MockService.run's completion block will give you the url String to point your API client to.

@surpher surpher closed this as completed May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants