Search code examples
datacontractpactcontract

Consumer-Driven Contract Testing Databases


I recently learned about consumer-driven contract testing to supplement complex integration/E2E testing. I would like to verify my database and service are in sync through a contract. Is someone aware of how to do this?


Solution

  • If you are talking about an SQL relational database (where you would write a contract using a "mock" database, and then verify against a real one) there is no existing Pact solution for this (though it has been considered in a very abstract way before).

    If you're talking about a documented oriented database, where the data is basically just a JSON document, then you can use the underlying Pact matching code to ensure that the document structure in the database and what your code thinks the document structure is, are in sync. The specifics on this will depend on which language you are using however.

    Hop on to https://slack.pact.io if you would like to discuss it more with the Pact maintainers and users.