From 2a693be5535c9523e74180e05a5608e29339bf52 Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Wed, 22 Apr 2020 15:54:24 +0530 Subject: [PATCH] cli(test): fix cli init test to use initDir from subtest group (#4490) --- .circleci/test-cli.sh | 2 +- cli/integration_test/v1/init.go | 10 +--------- cli/integration_test/v2/init.go | 10 +--------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/.circleci/test-cli.sh b/.circleci/test-cli.sh index 3f00cbecbc9..350f4ef6d9d 100755 --- a/.circleci/test-cli.sh +++ b/.circleci/test-cli.sh @@ -29,7 +29,7 @@ PID=$! wait_for_port 8080 # test cli -HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" TEST_TAGS="test_plugins" make test +HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test kill -s INT $PID # start graphql-engine with admin secret diff --git a/cli/integration_test/v1/init.go b/cli/integration_test/v1/init.go index 1401bf544d2..50573e174f2 100644 --- a/cli/integration_test/v1/init.go +++ b/cli/integration_test/v1/init.go @@ -1,21 +1,13 @@ package v1 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 @@ -27,7 +19,7 @@ func TestInitCmd(t *testing.T, ec *cli.ExecutionContext, initDir string) { Version: cli.V1, 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))), + InitDir: initDir, }, nil}, } diff --git a/cli/integration_test/v2/init.go b/cli/integration_test/v2/init.go index 55aa7665681..62dc343878f 100644 --- a/cli/integration_test/v2/init.go +++ b/cli/integration_test/v2/init.go @@ -1,21 +1,13 @@ 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 @@ -27,7 +19,7 @@ func TestInitCmd(t *testing.T, ec *cli.ExecutionContext, initDir string) { Version: cli.V2, 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))), + InitDir: initDir, }, nil}, }