I am busy experimenting with setting some of my te...
# general
s
I am busy experimenting with setting some of my teams up with pact, and I thought I had everything under control until I realised that one of my teams is using OData. So I have some questions regarding good practice. Are there any recommendations for scenarios where an API call will have two http requests under the hood? When making a request for a resource with OData there will be a metadata request for available resources, should I • find a way to intercept the meta data call so it doesn't get to the mock services? • handle both requests in the mock service? If it's the latter, is there documentation for this? I'm using dotnet (and from history, am bad at finding things in documentation 😞 ). I'm not sure if this is strictly a dotnet issue or relating to the mock server (and hopefully everyone is getting the joy of something built in rust).
after some persistence, I've realised that I can resolve my issue by requesting the metadata with the OData client, which then caches the metadata and it will be available for later tests. of course, this means that later tests are dependant on this data. it seems liveable to me.
m
That might be workable. I wouldn’t over think it unless it’s causing problems
• find a way to intercept the meta data call so it doesn’t get to the mock services?
Not in Pact, but most test frameworks these days have a way to do that. e.g. in JS you might use
nock
, or even just stub the metadata function directly. I would go this route if you must. We do have an old blog on a related topic (HAL/Siren), the use case is slightly different but will share it just in case: https://pactflow.io/blog/dealing-with-hypermedia-with-pact-tests/ Example project (in JS): https://github.com/pactflow/example-siren
👍 1
s
Thanks!
👍 1