functional: Test DBs use migrations

All repo tests build their tables by applying all the migrations. This
way we know our migrations are functional.
This commit is contained in:
Bobby Rullo 2015-08-19 15:40:59 -07:00
parent c16e3b5a10
commit 84bc8073de
2 changed files with 8 additions and 4 deletions

View file

@ -40,10 +40,12 @@ func connect(t *testing.T) *gorp.DbMap {
t.Fatalf("Unable to drop database tables: %v", err)
}
if err = c.CreateTablesIfNotExists(); err != nil {
t.Fatalf("Unable to create database tables: %v", err)
if err = db.DropMigrationsTable(c); err != nil {
panic(fmt.Sprintf("Unable to drop migration table: %v", err))
}
db.MigrateToLatest(c)
return c
}

View file

@ -18,8 +18,10 @@ func initDB(dsn string) *gorp.DbMap {
panic(fmt.Sprintf("Unable to drop database tables: %v", err))
}
if err = c.CreateTablesIfNotExists(); err != nil {
panic(fmt.Sprintf("Unable to create database tables: %v", err))
if err = db.DropMigrationsTable(c); err != nil {
panic(fmt.Sprintf("Unable to drop migration table: %v", err))
}
db.MigrateToLatest(c)
return c
}