Our great sponsors
-
Hi, recently I wrote a small NoSQL embedded database in Go. It is meant to run as a library, for those usa cases where you don't want to run a real database server. I leave here the link: https://github.com/ostafen/clover Maybe, it can be of help
-
dockertest
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work.
Hey, If you just want to run tests against database normally I just use an interface for repository methods, and initialise a new repository connected to a new Database, personally I usually use dockertest . I launch a docker for the test DB instance, and use a defer method to drop the used table after each test. Doing this you can contain the instance of docker with DB locally and it's automatically managed by docker test.
-
InfluxDB
Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.
-
You can test the code outside those data classes using more general mocks. https://github.com/golang/mock
-
keploy
Testing for Developers. Toolkit that creates test-cases and data mocks from API calls, DB queries, etc.
You could also try Keploy . It can not only automatically manage mocking for you but also save the requests you perform as unit tests.
-
A lot of good suggestions here, I would also take a look at go-testfixtures which allows you to create some simple yaml-based fixture data to use with unit testing. It's quick and easy, but yes can get unwieldy the more you add.
-
SonarLint
Clean code begins in your IDE with SonarLint. Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.