I'm trying to test my routes handlers written in Go with Gin Gonic Framework.
For testing with Gin, I can see here: https://github.com/gin-gonic/gin#testing
to test interactions with InfluxDB, I have 3 choices:
- Mock InfluxDB
- Set a testing InfluxDB in the cloud
- Set a local testing InfluxDB for each tests in CI
The reason I post this question is that none of them seems good enough.
The test I want to perform is checking that an object is created in DB.
so, I will make a POST on my endpoint, pass him a body with the data to be created, and check with another query that Database container the newly created object.
With 1, tests are quite static, they can pass when they should not. With 2, there is no helpers to reset the DB after each tests, so I find it hard to implement With 3, I find it very heavy to mount all the needed infrastructure for each tests.
I'm a newbie in Go, so I don't really know what should be my approach.
Before, I worked with Laravel or NodeJS, and those framework have built in tools that make functional testing very confortable.
Can anybody tell me what should be a standart approach to testing an API with Go / Gin, and some NoSQL DB ?
Aucun commentaire:
Enregistrer un commentaire