hey all! Based on this doc <Consumer-Driven Contr...
# documentation
g
hey all! Based on this doc Consumer-Driven Contract Testing CI/CD Workshop there is two main repository: • example-consumerexample-provider I must do the same If I want to apply for my application ? I mean, do I need to create a repo for consumer e other for provider? thanks!
👋 1
m
Are you asking if you should have two separate repositories for your applications to do contract testing, or just to run the workshop?
g
actually both, i mean, i didn't get why we have to separate them, is it possible to create two yml file?
m
I’m sorry I’m struggling to understand the question/issue. What are you trying to do? Most applications are in their own repository (i.e. not a monorepo), so we have created our workshops to mirror that. Each application would normally have its own CI/CD pipeline independent from others. In these examples, both use GitHub Actions.
g
My point is that did you created those two repo only for this workshop? I mean, do i have to do the same or I can use one single yml file which contains the consumer test and provider test....
m
Yes these are for demonstration purposes. If your consumer and provider are in the same repo you can do that.
👍 1
But it is unusual. Could you please explain why you want to do that?
g
in my project we have a monorepo
👍 1
hey @Matt (pactflow.io / pact-js / pact-go) sorry but i have another questions, do i need to follow those steps: • run the Consumer Tests • publish the pact files at Pact Broker • run the Provider verification I mean, to fully do the consumer-driven contract testing i have to follow those steps, correct?
i'm asking that because i'm getting failed results after run the provider so i believe i have to publish the pacts before run the provider, is that correct?!
m
Yes, you should publish the pacts (otherwise you won’t be able to publish verification results back to PactFlow/Broker)
👍 1
but the issue you have there is unrelated to that, it’s failing because your provider is unable to verify the contract
g
I see, Yes im trying to solve that! Thanks
👍 1
hey @Matt (pactflow.io / pact-js / pact-go) I'm still debugging those failing tests! you said "your provider is unable to verify the contract" i reviewed my consumer.spec and my service as well and they looks good, just to be sure about the steps: 1 - after run the consumer tests 2 - json files will be generated at pacts folder 3 - provider tests will grab those json files to verify them is that correct or i'm forgetting something?
m
Yes, albeit you usually would publish them to a broker and verify from a broker. Bits it's ok to do without
The failure above shows your provider is returning a 401 but was expecting a 200
So it's a failing test, the setup itself seems to be working
Howtolearn
s
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops
m
There's a JS workshop that talks about how to test auth there that might help
g
I don't know the reason to return 401 since i'm looking at the pacts folder, however i'll publish then run the provider checking the pacts from brokerurl
without a broker i can simple point to the pacts folder using:
Copy code
pactUrls: [
        path.resolve(
          process.cwd(),
          './pacts/mySoncumerFile.json'
        ),
      ]
m
the
401
is coming from your provider API. I’m guessing there is an authentication layer on it, and the pact request is getting caught in it