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:
parent
c16e3b5a10
commit
84bc8073de
2 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Reference in a new issue