Skip to content

tborisova/clean_like_gopher

Folders and files

NameName
Last commit message
Last commit date
Feb 20, 2015
Jan 18, 2015
Feb 12, 2017
Jul 26, 2016
Jul 26, 2016
Feb 21, 2015
Feb 21, 2015
Jul 26, 2016
Jul 26, 2016
Jul 26, 2016
Jul 26, 2016
Feb 21, 2015
Feb 1, 2015
Jul 26, 2016

Repository files navigation

Clean like gopher

Clean like gopher is inspired from database_cleaner. The purpose of clean like gopher is to ensure that the DB is clean between tests.

GoDoc

TODO:

  • Add transaction for mysql
  • Implement redis cleaner
  • Use ginkgo for test
  • Write better tests for different strategies

Supported drivers

Install:

  go get "github.com/tborisova/clean_like_gopher"

Usage

  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

Examples:

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