graphql-engine/cli/commands/scripts_update_config_v2_test.go
Kali Vara Purushotham Santhati 2aeb6ad0b1 cli: use absolute path of project directory
closes https://github.com/hasura/graphql-engine/issues/7089
closes https://github.com/hasura/graphql-engine/issues/6499

https://github.com/hasura/graphql-engine-mono/pull/1717

Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 74209e249c692d01f2bd849181c8a2ef46493e74
2021-07-16 12:59:04 +00:00

58 lines
1.8 KiB
Go

package commands
import (
"fmt"
"github.com/hasura/graphql-engine/cli/v2/internal/testutil"
"github.com/hasura/graphql-engine/cli/v2/util"
. "github.com/onsi/ginkgo"
"io/ioutil"
"path/filepath"
. "github.com/onsi/gomega"
//. "github.com/onsi/gomega/gbytes"
//. "github.com/onsi/gomega/gexec"
)
var _ = Describe("hasura scripts update-project-v2", func() {
var teardown func()
var hgeEndpoint string
BeforeEach(func() {
// start cli-migrations (config v1)
connectionUrl, teardownPG := testutil.StartPGContainer(GinkgoT())
_, teardownV13 := testutil.StartHasuraCLIMigrations(
GinkgoT(),
"hasura/graphql-engine:v1.3.3.cli-migrations",
connectionUrl,
"",
func() string {
s, err := filepath.Abs("testdata/config-v1-test-project/migrations")
Expect(err).To(BeNil())
return s
}(),
)
teardownV13()
port, teardownLatest := testutil.StartHasuraWithPG(GinkgoT(), testutil.HasuraDockerImage, connectionUrl)
hgeEndpoint = fmt.Sprintf("http://%s:%s", testutil.Hostname, port)
teardown = func() {
teardownPG()
teardownLatest()
}
})
AfterEach(func() { teardown() })
It("can update a config v1 project to config v2", func() {
tmpDir, err := ioutil.TempDir("", "hasura-cli-test-*")
Expect(err).To(BeNil())
projectDir := filepath.Join(tmpDir, "project")
Expect(util.CopyDir("testdata/config-v1-test-project", projectDir)).To(BeNil())
editEndpointInConfig(filepath.Join(projectDir, defaultConfigFilename), hgeEndpoint)
testutil.RunCommandAndSucceed(testutil.CmdOpts{
Args: []string{"scripts", "update-project-v2"},
WorkingDirectory: projectDir,
})
Expect(filepath.Join(projectDir, "metadata", "tables.yaml")).To(BeAnExistingFile())
Expect(filepath.Join(projectDir, "migrations", "1626431381198_create_table_public_t1", "up.sql")).To(BeAnExistingFile())
})
})