graphql-engine/cli/commands/metadata_clear_test.go
Naveen Naidu d10b862b61 server: fix bugs in clear_metadata code path
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3927
Co-authored-by: Divi <32202683+imperfect-fourth@users.noreply.github.com>
Co-authored-by: Karthikeyan Chinnakonda <15602904+codingkarthik@users.noreply.github.com>
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: 6f3457698029af94e9157c23b552ac2034f9c740
2022-04-11 11:25:13 +00:00

69 lines
1.8 KiB
Go

package commands
import (
"fmt"
"os"
"path/filepath"
"github.com/Pallinder/go-randomdata"
"github.com/hasura/graphql-engine/cli/v2/internal/testutil"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("hasura metadata clear", func() {
var projectDirectory string
var teardown func()
BeforeEach(func() {
projectDirectory = testutil.RandDirName()
t := GinkgoT()
sourceName := randomdata.SillyName()
connectionString, teardownPG := testutil.StartPGContainer(t)
hgeEndPort, teardownHGE := testutil.StartHasuraWithPG(t, testutil.HasuraDockerImage, connectionString)
hgeEndpoint := fmt.Sprintf("http://0.0.0.0:%s", hgeEndPort)
copyTestConfigV3Project(projectDirectory)
editEndpointInConfig(filepath.Join(projectDirectory, defaultConfigFilename), hgeEndpoint)
editSourceNameInConfigV3ProjectTemplate(projectDirectory, sourceName, connectionString)
teardown = func() {
os.RemoveAll(projectDirectory)
teardownPG()
teardownHGE()
}
})
AfterEach(func() {
teardown()
})
Context("metadata clear test", func() {
It("should clear metadata on server", func() {
testutil.RunCommandAndSucceed(testutil.CmdOpts{
Args: []string{"metadata", "apply"},
WorkingDirectory: projectDirectory,
})
session := testutil.Hasura(testutil.CmdOpts{
Args: []string{"metadata", "clear"},
WorkingDirectory: projectDirectory,
})
Eventually(session, timeout).Should(Exit(0))
Expect(session.Err.Contents()).Should(ContainSubstring("Metadata cleared"))
session = testutil.Hasura(testutil.CmdOpts{
Args: []string{"metadata", "diff"},
WorkingDirectory: projectDirectory,
})
Eventually(session, timeout).Should(Exit(0))
stdout := session.Out.Contents()
Expect(stdout).Should(ContainSubstring("tables"))
})
})
})