i want write integration test uses mysql test queries. how in golang?
this contains few questions:
- how setup mysql (in-memory?) server in golang test?
- how clean/recreate data model before/after each test not leave garbage behind?
- how tear down mysql after tests done?
if want have embedded mysql, can use golangs c bindings integrate with: https://dev.mysql.com/doc/refman/5.1/en/libmysqld.html. haven't seen project packing bindings in nice go package, interesting small project.
otherwise can use docker set throwaway mysql server, requires setup/teardown steps before run go test though. doing work.
in both cases, need write setup/teardown methods creates , drops tables needed tests. these normal sql statements, drop database, create table etc.
testify https://github.com/stretchr/testify has tooling setup/teardown, writing helper function works fine.