2018-06-28 11:36:57 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/briandowns/spinner"
|
|
|
|
"github.com/hasura/graphql-engine/cli"
|
|
|
|
"github.com/sirupsen/logrus/hooks/test"
|
2019-03-18 19:40:04 +03:00
|
|
|
"github.com/spf13/pflag"
|
2018-06-28 11:36:57 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMigrateCreateCmd(t *testing.T) {
|
|
|
|
logger, _ := test.NewNullLogger()
|
|
|
|
opts := &migrateCreateOptions{
|
|
|
|
EC: &cli.ExecutionContext{
|
|
|
|
Logger: logger,
|
|
|
|
Spinner: spinner.New(spinner.CharSets[7], 100*time.Millisecond),
|
|
|
|
MigrationDir: filepath.Join(os.TempDir(), "hasura-cli-test-"+strconv.Itoa(rand.Intn(1000))),
|
|
|
|
},
|
2019-03-18 19:40:04 +03:00
|
|
|
name: "create_article",
|
|
|
|
flags: pflag.NewFlagSet("migrate-create-test", pflag.ContinueOnError),
|
2018-06-28 11:36:57 +03:00
|
|
|
}
|
|
|
|
|
2018-06-28 11:44:01 +03:00
|
|
|
err := opts.run()
|
2018-06-28 11:36:57 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed creating migration: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
os.RemoveAll(opts.EC.MigrationDir)
|
|
|
|
}
|