graphql-engine/cli/commands/migrate_create_test.go

34 lines
705 B
Go
Raw Normal View History

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",
}
2018-06-28 11:44:01 +03:00
err := opts.run()
if err != nil {
t.Fatalf("failed creating migration: %v", err)
}
os.RemoveAll(opts.EC.MigrationDir)
}