Skip to content

Commit

Permalink
Merge pull request pressly#58 from pressly/travis
Browse files Browse the repository at this point in the history
Move tests from .travis.yml to goose_test.go
  • Loading branch information
VojtechVitek authored Jun 21, 2017
2 parents aa0240c + ae2fff1 commit a0e07f5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,3 @@ install:

script:
- go test
- go build -i -o goose ./cmd/goose
- ./goose -dir=examples/sql-migrations sqlite3 sql.db up
- ./goose -dir=examples/sql-migrations sqlite3 sql.db version
- ./goose -dir=examples/sql-migrations sqlite3 sql.db down
- ./goose -dir=examples/sql-migrations sqlite3 sql.db status
- go build -i -o custom-goose ./examples/go-migrations
- ./custom-goose -dir=examples/go-migrations sqlite3 go.db up
- ./custom-goose -dir=examples/go-migrations sqlite3 go.db version
- ./custom-goose -dir=examples/go-migrations sqlite3 go.db down
- ./custom-goose -dir=examples/go-migrations sqlite3 go.db status
43 changes: 43 additions & 0 deletions goose_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package goose

import (
"os/exec"
"strings"
"testing"
)

func TestDefaultBinary(t *testing.T) {
commands := []string{
"go build -i -o goose ./cmd/goose",
"./goose -dir=examples/sql-migrations sqlite3 sql.db up",
"./goose -dir=examples/sql-migrations sqlite3 sql.db version",
"./goose -dir=examples/sql-migrations sqlite3 sql.db down",
"./goose -dir=examples/sql-migrations sqlite3 sql.db status",
}

for _, cmd := range commands {
args := strings.Split(cmd, " ")
out, err := exec.Command(args[0], args[1:]...).CombinedOutput()
if err != nil {
t.Fatalf("%s:\n%v\n\n%s", err, cmd, out)
}
}
}

func TestCustomBinary(t *testing.T) {
commands := []string{
"go build -i -o custom-goose ./examples/go-migrations",
"./custom-goose -dir=examples/go-migrations sqlite3 go.db up",
"./custom-goose -dir=examples/go-migrations sqlite3 go.db version",
"./custom-goose -dir=examples/go-migrations sqlite3 go.db down",
"./custom-goose -dir=examples/go-migrations sqlite3 go.db status",
}

for _, cmd := range commands {
args := strings.Split(cmd, " ")
out, err := exec.Command(args[0], args[1:]...).CombinedOutput()
if err != nil {
t.Fatalf("%s:\n%v\n\n%s", err, cmd, out)
}
}
}

0 comments on commit a0e07f5

Please sign in to comment.