diff --git a/.travis.yml b/.travis.yml index 91911dd..09d0d7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/goose_test.go b/goose_test.go new file mode 100644 index 0000000..4fe28b2 --- /dev/null +++ b/goose_test.go @@ -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) + } + } +}