Skip to content

Commit

Permalink
Also test against PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynering committed Jul 15, 2018
1 parent 359cb9b commit 3596971
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .sample.env
@@ -1 +1,2 @@
SQLITE_CONN_STRING: :memory:
SQLITE_CONN_STRING=:memory:
PG_CONN_STRING="user=postgres dbname=gormigrate_test sslmode=disable"
10 changes: 10 additions & 0 deletions Taskfile.yml
Expand Up @@ -8,6 +8,10 @@ tasks:
cmds:
- go get -u github.com/golang/lint/golint

go-get-all:
cmds:
- go get -v -t -tags 'sqlite postgresql' ./...

lint:
desc: Runs golint on this project
cmds:
Expand All @@ -19,6 +23,12 @@ tasks:
- task: test
vars: {DATABASE: sqlite}

test-pg:
desc: Run tests for PostgreSQL
cmds:
- task: test
vars: {DATABASE: postgresql}

test:
cmds:
- go test -v -tags {{.DATABASE}}
4 changes: 4 additions & 0 deletions gormigrate_test.go
Expand Up @@ -145,6 +145,10 @@ func forEachDatabase(t *testing.T, fn func(database *gorm.DB)) {
assert.NoError(t, err, "Could not connect to database %s, %v", database.name, err)

defer db.Close()

// ensure tables do not exists
assert.NoError(t, db.DropTableIfExists("migrations", "people", "pets").Error)

fn(db)
}
}
14 changes: 14 additions & 0 deletions postgresql_test.go
@@ -0,0 +1,14 @@
// +build postgresql

package gormigrate

import (
_ "github.com/jinzhu/gorm/dialects/postgres"
)

func init() {
databases = append(databases, database{
name: "postgres",
connEnv: "PG_CONN_STRING",
})
}

0 comments on commit 3596971

Please sign in to comment.