如何设置golang集成测试的环境要求?

I am new to golang and have two little projects started, where I got to the same problem.

One uses a MySQL database as a datastore and the other elasticsearch. How can I write tests which cover the code for that.

At first I’ve used a HashMapDatastore, but with that I can only test my handlers and business logic, but not the persistence layer (e.g. if the persisting and retrieving works as I expect in elasticsearch) (aka integration test).

So should I test if there is a blank database for testing? How should I delete this db after each test? I’ve found an approach for this in the integration tests of docker/libcompose but it is relatively complex.

Is there a common approach for that? Testing if there is an elasticsearch with an empty index available and if not failing the tests with a good setupmessage?

Thanks