mirror of https://github.com/pressly/goose.git
update tests to output binaries to bin
parent
2e097bc085
commit
d133095bcc
|
@ -4,11 +4,8 @@ cmd/goose/goose*
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
# Files output by tests
|
# Files output by tests
|
||||||
custom-goose
|
bin
|
||||||
go.db
|
go.db
|
||||||
goose
|
|
||||||
sql.db
|
sql.db
|
||||||
|
|
||||||
|
|
||||||
# don't ignore goose dir
|
|
||||||
!goose/
|
|
||||||
|
|
18
fix_test.go
18
fix_test.go
|
@ -20,12 +20,12 @@ func TestFix(t *testing.T) {
|
||||||
defer os.Remove("goose") // clean up
|
defer os.Remove("goose") // clean up
|
||||||
|
|
||||||
commands := []string{
|
commands := []string{
|
||||||
"go build -i -o goose ./cmd/goose",
|
"go build -i -o ./bin/goose ./cmd/goose",
|
||||||
fmt.Sprintf("./goose -dir=%s create create_table", dir),
|
fmt.Sprintf("./bin/goose -dir=%s create create_table", dir),
|
||||||
fmt.Sprintf("./goose -dir=%s create add_users", dir),
|
fmt.Sprintf("./bin/goose -dir=%s create add_users", dir),
|
||||||
fmt.Sprintf("./goose -dir=%s create add_indices", dir),
|
fmt.Sprintf("./bin/goose -dir=%s create add_indices", dir),
|
||||||
fmt.Sprintf("./goose -dir=%s create update_users", dir),
|
fmt.Sprintf("./bin/goose -dir=%s create update_users", dir),
|
||||||
fmt.Sprintf("./goose -dir=%s fix", dir),
|
fmt.Sprintf("./bin/goose -dir=%s fix", dir),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range commands {
|
for _, cmd := range commands {
|
||||||
|
@ -52,9 +52,9 @@ func TestFix(t *testing.T) {
|
||||||
|
|
||||||
// add more migrations and then fix it
|
// add more migrations and then fix it
|
||||||
commands = []string{
|
commands = []string{
|
||||||
fmt.Sprintf("./goose -dir=%s create remove_column", dir),
|
fmt.Sprintf("./bin/goose -dir=%s create remove_column", dir),
|
||||||
fmt.Sprintf("./goose -dir=%s create create_books_table", dir),
|
fmt.Sprintf("./bin/goose -dir=%s create create_books_table", dir),
|
||||||
fmt.Sprintf("./goose -dir=%s fix", dir),
|
fmt.Sprintf("./bin/goose -dir=%s fix", dir),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range commands {
|
for _, cmd := range commands {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package goose
|
package goose
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -8,11 +11,11 @@ import (
|
||||||
|
|
||||||
func TestDefaultBinary(t *testing.T) {
|
func TestDefaultBinary(t *testing.T) {
|
||||||
commands := []string{
|
commands := []string{
|
||||||
"go build -i -o goose ./cmd/goose",
|
"go build -i -o ./bin/goose ./cmd/goose",
|
||||||
"./goose -dir=examples/sql-migrations sqlite3 sql.db up",
|
"./bin/goose -dir=examples/sql-migrations sqlite3 sql.db up",
|
||||||
"./goose -dir=examples/sql-migrations sqlite3 sql.db version",
|
"./bin/goose -dir=examples/sql-migrations sqlite3 sql.db version",
|
||||||
"./goose -dir=examples/sql-migrations sqlite3 sql.db down",
|
"./bin/goose -dir=examples/sql-migrations sqlite3 sql.db down",
|
||||||
"./goose -dir=examples/sql-migrations sqlite3 sql.db status",
|
"./bin/goose -dir=examples/sql-migrations sqlite3 sql.db status",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range commands {
|
for _, cmd := range commands {
|
||||||
|
@ -25,15 +28,23 @@ func TestDefaultBinary(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLiteBinary(t *testing.T) {
|
func TestLiteBinary(t *testing.T) {
|
||||||
|
dir, err := ioutil.TempDir("", "tmptest")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer os.RemoveAll(dir) // clean up
|
||||||
|
defer os.Remove("goose") // clean up
|
||||||
|
|
||||||
commands := []string{
|
commands := []string{
|
||||||
"./goose -dir=examples/sql-migrations create user_indices sql",
|
fmt.Sprintf("./bin/goose -dir=%s create user_indices sql", dir),
|
||||||
"./goose -dir=examples/sql-migrations fix",
|
fmt.Sprintf("./bin/goose -dir=%s fix", dir),
|
||||||
}
|
}
|
||||||
|
|
||||||
// this has to be done outside of the loop
|
// this has to be done outside of the loop
|
||||||
// since go only supports space separated tags list.
|
// since go only supports space separated tags list.
|
||||||
cmd := "go build -tags='no_mysql no_sqlite no_psql' -i -o goose ./cmd/goose"
|
cmd := "go build -tags='no_mysql no_sqlite no_psql' -i -o ./bin/goose ./cmd/goose"
|
||||||
out, err := exec.Command("go", "build", "-tags='no_mysql no_sqlite no_psql'", "-i", "-o", "goose", "./cmd/goose").CombinedOutput()
|
out, err := exec.Command("go", "build", "-tags='no_mysql no_sqlite no_psql'", "-i", "-o", "./bin/goose", "./cmd/goose").CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%s:\n%v\n\n%s", err, cmd, out)
|
t.Fatalf("%s:\n%v\n\n%s", err, cmd, out)
|
||||||
}
|
}
|
||||||
|
@ -49,11 +60,11 @@ func TestLiteBinary(t *testing.T) {
|
||||||
|
|
||||||
func TestCustomBinary(t *testing.T) {
|
func TestCustomBinary(t *testing.T) {
|
||||||
commands := []string{
|
commands := []string{
|
||||||
"go build -i -o custom-goose ./examples/go-migrations",
|
"go build -i -o ./bin/custom-goose ./examples/go-migrations",
|
||||||
"./custom-goose -dir=examples/go-migrations sqlite3 go.db up",
|
"./bin/custom-goose -dir=examples/go-migrations sqlite3 go.db up",
|
||||||
"./custom-goose -dir=examples/go-migrations sqlite3 go.db version",
|
"./bin/custom-goose -dir=examples/go-migrations sqlite3 go.db version",
|
||||||
"./custom-goose -dir=examples/go-migrations sqlite3 go.db down",
|
"./bin/custom-goose -dir=examples/go-migrations sqlite3 go.db down",
|
||||||
"./custom-goose -dir=examples/go-migrations sqlite3 go.db status",
|
"./bin/custom-goose -dir=examples/go-migrations sqlite3 go.db status",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range commands {
|
for _, cmd := range commands {
|
||||||
|
|
Loading…
Reference in New Issue