mardi 12 novembre 2019

How to perform integration tests on micro-services using hasura?

I finally made that step forward towards micro-service architecture, and, in particular, 3 factor app, which I find cool.

Therefore, I decided to start building my backend with hasura, as it is blazing fast and is crazy about the event system.

However, I am already facing my first difficult problem: I would like to have acceptance for my backend. To do so, I'd like to perform kind of end-to-end calls to my backend. For example, I would like to call a mutation on my hasura api in such an acceptance test and revert the database back to its state before running the test scenario.

What are the best practices in that context? How can I rollback the database until just right before the mutation was called?

I know how I would do it with a pure postgres database, without the intermediate hasura engine. The thing is that now my acceptance tests are calling mutations that do not provide me with direct access to a postgres transaction, leaving me with no evident way to restore my database to its original state before a test scenario was run.

I tried to use stellar but it's not really working well. I could also recreate the database everytime I run a new scenario, but that'd be very inefficient. I read about hasura auditing, maybe that's the way to go? How do you acceptance / integration test your hasura backends?

Aucun commentaire:

Enregistrer un commentaire