Hey there, good morning :sun_with_face: I’m new to...
# pact-jvm
f
Hey there, good morning 🌞 I’m new to Pact, been trying to set up a contract but I can’t find enough info online and idk if I’m missing something I’ve got two services (frontend with React + back with Java), trying to set up a contract test between them (is it possible between different technologies? I imagine so, but every tutorial I’ve found is between the same technologies) I set up a test in the consumer (React), copy pasted the test to the provider (java) and set up a test. The test is testing something that goes green for a unit test. After passing it a string it should return a succesful 204 message. However, I’m seeing it return 502 🤔 It’s driving me insane cause the unit test runs well, so I imagine it’s not the logic. The provider name matches, the url matches (if it doesn’t it just returns 404, so I know I’m pointing to the right one). The only thing that occurs to me is that it may have to be with the metadata since it’s between two different technologies and I haven’t specified that anywhere? Could someone give me a hand?
This is what the contract looks like after being generated by the consumer
Copy code
{
  "consumer": {
    "name": "verification-ui"
  },
  "interactions": [
    {
      "description": "the email address for a valid guid",
      "providerStates": [
        {
          "name": "returns a 204"
        }
      ],
      "request": {
        "body": {
          "guid": "some-guid"
        },
        "headers": {
          "Content-Type": "application/json"
        },
        "method": "POST",
        "path": "/api/v1/verify-email-address"
      },
      "response": {
        "body": {},
        "headers": {
          "Content-Type": "application/json"
        },
        "status": 204
      }
    }
  ],
  "metadata": {
    "pact-js": {
      "version": "10.4.1"
    },
    "pactRust": {
      "ffi": "0.4.0",
      "models": "1.0.4"
    },
    "pactSpecification": {
      "version": "3.0.0"
    }
  },
  "provider": {
    "name": "account"
  }
}
t
is it possible between different technologies?
Yes. This is a major selling point of Pact
🙌 1
After passing it a string it should return a succesful 204 message. However, I’m seeing it return 502
Pact doesn’t return 502, so this is probably a misconfiguration in your code
The only thing that occurs to me is that it may have to be with the metadata since it’s between two different technologies and I haven’t specified that anywhere?
No, I don’t think this is related.
What happens if you spin up the server like you were about to test it, and then did that POST request via curl?
This is what the contract looks like after being generated by the consumer
Aside - but you should never need to look in the contract file. You can generally treat it as opaque (although in this case it’s helpful, as we can see what you’re trying to do with it)
1
f
Ah sorry, forgot to say this, but if I spin it up and hit the endpoint I also get a 502, but that’s an SQL error, which I understand happens when the whole flow is run in local, but with the contract test I’m mocking the answer past the controller, so I would expect it not to care 😕
t
I reckon signs point to the mock isn’t applying for some reason
This feels like it’s not Pact at fault - (but it might be order of setup / invocation of the Pact verification)
It might be helpful if you can share the way you’re setting up your test - although I don’t do much with the JVM so I personally might not be able to help
f
I can share that, but it’s pretty similar to the one provided in the workshop I think. Only thing I’m not able to add is the @SpringBootTest annotation cause it throws a “Failed to load ApplicationContext”