mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-13 08:30:03 +01:00
Move tests out of separate package
This commit is contained in:
parent
1d2493d2be
commit
275f5791f4
5 changed files with 36 additions and 62 deletions
|
|
@ -1,10 +1,8 @@
|
|||
package postgres_test
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"github.com/adrianmacneil/dbmate/driver/postgres"
|
||||
"github.com/stretchr/testify/require"
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"testing"
|
||||
|
|
@ -25,14 +23,8 @@ func testURL(t *testing.T) *url.URL {
|
|||
return u
|
||||
}
|
||||
|
||||
func mustClose(c io.Closer) {
|
||||
if err := c.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func prepTestDB(t *testing.T) *sql.DB {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
u := testURL(t)
|
||||
|
||||
// drop any existing database
|
||||
|
|
@ -51,7 +43,7 @@ func prepTestDB(t *testing.T) *sql.DB {
|
|||
}
|
||||
|
||||
func TestCreateDropDatabase(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
u := testURL(t)
|
||||
|
||||
// drop any existing database
|
||||
|
|
@ -89,7 +81,7 @@ func TestCreateDropDatabase(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDatabaseExists(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
u := testURL(t)
|
||||
|
||||
// drop any existing database
|
||||
|
|
@ -112,7 +104,7 @@ func TestDatabaseExists(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDatabaseExists_Error(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
u := testURL(t)
|
||||
u.User = url.User("invalid")
|
||||
|
||||
|
|
@ -122,7 +114,7 @@ func TestDatabaseExists_Error(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateMigrationsTable(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
db := prepTestDB(t)
|
||||
defer mustClose(db)
|
||||
|
||||
|
|
@ -145,7 +137,7 @@ func TestCreateMigrationsTable(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSelectMigrations(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
db := prepTestDB(t)
|
||||
defer mustClose(db)
|
||||
|
||||
|
|
@ -171,7 +163,7 @@ func TestSelectMigrations(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInsertMigration(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
db := prepTestDB(t)
|
||||
defer mustClose(db)
|
||||
|
||||
|
|
@ -194,7 +186,7 @@ func TestInsertMigration(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteMigration(t *testing.T) {
|
||||
drv := postgres.Driver{}
|
||||
drv := Driver{}
|
||||
db := prepTestDB(t)
|
||||
defer mustClose(db)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue