graphql-engine/cli/commands/migrate_create_test.go
2018-06-28 14:14:01 +05:30

34 lines
705 B
Go

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"
)
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))),
},
name: "create_article",
}
err := opts.run()
if err != nil {
t.Fatalf("failed creating migration: %v", err)
}
os.RemoveAll(opts.EC.MigrationDir)
}