forked from pressly/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goose_test.go
43 lines (38 loc) · 1.19 KB
/
goose_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)
}
}
}