2021-04-05 17:00:21 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/hasura/graphql-engine/cli/internal/testutil"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
. "github.com/onsi/gomega/gexec"
|
|
|
|
)
|
|
|
|
|
2021-06-03 16:26:28 +03:00
|
|
|
var _ = Describe("hasura metadata reload", func() {
|
2021-04-05 17:00:21 +03:00
|
|
|
|
|
|
|
var dirName string
|
|
|
|
var teardown func()
|
|
|
|
BeforeEach(func() {
|
|
|
|
dirName = testutil.RandDirName()
|
2021-06-03 16:26:28 +03:00
|
|
|
hgeEndPort, teardownHGE := testutil.StartHasura(GinkgoT(), testutil.HasuraDockerImage)
|
2021-04-05 17:00:21 +03:00
|
|
|
hgeEndpoint := fmt.Sprintf("http://0.0.0.0:%s", hgeEndPort)
|
|
|
|
testutil.RunCommandAndSucceed(testutil.CmdOpts{
|
|
|
|
Args: []string{"init", dirName},
|
|
|
|
})
|
|
|
|
editEndpointInConfig(filepath.Join(dirName, defaultConfigFilename), hgeEndpoint)
|
|
|
|
|
|
|
|
teardown = func() {
|
|
|
|
os.RemoveAll(dirName)
|
|
|
|
teardownHGE()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-06-03 16:26:28 +03:00
|
|
|
AfterEach(func() { teardown() })
|
2021-04-05 17:00:21 +03:00
|
|
|
|
|
|
|
Context("metadata reload test", func() {
|
|
|
|
It("should reload metadata", func() {
|
2021-06-03 16:26:28 +03:00
|
|
|
session := testutil.Hasura(testutil.CmdOpts{
|
2021-04-05 17:00:21 +03:00
|
|
|
Args: []string{"metadata", "reload"},
|
|
|
|
WorkingDirectory: dirName,
|
|
|
|
})
|
2021-05-14 22:09:01 +03:00
|
|
|
want := `Metadata reloaded`
|
2021-04-05 17:00:21 +03:00
|
|
|
Eventually(session, 60*40).Should(Exit(0))
|
2021-05-14 22:09:01 +03:00
|
|
|
Eventually(session.Wait().Err.Contents()).Should(ContainSubstring(want))
|
2021-04-05 17:00:21 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|