Clean like gopher is inspired from database_cleaner. The purpose of clean like gopher is to ensure that the DB is clean between tests.
- Add transaction for mysql
- Implement redis cleaner
- Use ginkgo for test
- Write better tests for different strategies
go get "github.com/tborisova/clean_like_gopher"
import 'github.com/tborisova/clean_like_gopher'
...
options := map[string]string{"host": "localhost", "dbName": "test", "port": "27017"}
m := clean_like_gopher.NewCleaningGopher("mongo", options) // clean collection 'test' using mongo driver and truncation strategy
...
dirty db
...
options = map[string]string{"strategy": "truncation"}
m.Clean(options) // clean all tables with truncation
m.Close() // after all specs or after each spec
Availabe strategies:
- For mysql/postgres:
- truncation(default), deletion, transaction (in future development)
- For mongo:
- truncation - default
- For redis:
- truncation - default
When using 'transaction' strategy you need to call Start() before the tests because it needs to know to open up a transaction.
Available options for truncation strategies:
- except: ["people", "animals"] - deletes all tables except 'people' and 'animals'
- only: ['people', 'animals'] - deletes only 'people' and 'animals' tables