mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
36 lines
805 B
Go
36 lines
805 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"
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
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",
|
|
flags: pflag.NewFlagSet("migrate-create-test", pflag.ContinueOnError),
|
|
}
|
|
|
|
err := opts.run()
|
|
if err != nil {
|
|
t.Fatalf("failed creating migration: %v", err)
|
|
}
|
|
|
|
os.RemoveAll(opts.EC.MigrationDir)
|
|
}
|