mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
bb63d7e60e
Co-authored-by: Rishichandra Wawhal <rishichandra.wawhal@gmail.com> Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com> Co-authored-by: Aravind <aravindkp@outlook.in> Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com> Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
44 lines
965 B
Go
44 lines
965 B
Go
package v2
|
|
|
|
import (
|
|
"math/rand"
|
|
"os"
|
|
"path/filepath"
|
|
"strconv"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/hasura/graphql-engine/cli"
|
|
"github.com/hasura/graphql-engine/cli/commands"
|
|
)
|
|
|
|
func init() {
|
|
rand.Seed(time.Now().UTC().UnixNano())
|
|
}
|
|
|
|
func TestInitCmd(t *testing.T, ec *cli.ExecutionContext, initDir string) {
|
|
tt := []struct {
|
|
name string
|
|
opts *commands.InitOptions
|
|
err error
|
|
}{
|
|
{"only-init-dir", &commands.InitOptions{
|
|
EC: ec,
|
|
Version: "2",
|
|
Endpoint: os.Getenv("HASURA_GRAPHQL_TEST_ENDPOINT"),
|
|
AdminSecret: os.Getenv("HASURA_GRAPHQL_TEST_ADMIN_SECRET"),
|
|
InitDir: filepath.Join(os.TempDir(), "hasura-cli-test-"+strconv.Itoa(rand.Intn(1000))),
|
|
}, nil},
|
|
}
|
|
|
|
for _, tc := range tt {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
err := tc.opts.Run()
|
|
if err != tc.err {
|
|
t.Fatalf("%s: expected %v, got %v", tc.name, tc.err, err)
|
|
}
|
|
// TODO: (shahidhk) need to verify the contents of the spec generated
|
|
})
|
|
}
|
|
}
|