2018-06-29 13:02:33 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2018-07-09 16:47:38 +03:00
|
|
|
"net/url"
|
2018-08-30 18:54:12 +03:00
|
|
|
"os"
|
2018-06-29 13:02:33 +03:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/briandowns/spinner"
|
|
|
|
"github.com/hasura/graphql-engine/cli"
|
2019-02-14 12:37:47 +03:00
|
|
|
"github.com/hasura/graphql-engine/cli/version"
|
2018-06-29 13:02:33 +03:00
|
|
|
"github.com/sirupsen/logrus/hooks/test"
|
|
|
|
)
|
|
|
|
|
2018-07-12 15:52:25 +03:00
|
|
|
func testMetadataApply(t *testing.T, metadataFile string, endpoint *url.URL) {
|
2018-06-29 13:02:33 +03:00
|
|
|
logger, _ := test.NewNullLogger()
|
|
|
|
opts := &metadataApplyOptions{
|
|
|
|
EC: &cli.ExecutionContext{
|
2018-07-12 15:52:25 +03:00
|
|
|
Logger: logger,
|
|
|
|
Spinner: spinner.New(spinner.CharSets[7], 100*time.Millisecond),
|
|
|
|
MetadataFile: metadataFile,
|
2019-02-14 12:37:47 +03:00
|
|
|
ServerConfig: &cli.ServerConfig{
|
2018-07-09 16:47:38 +03:00
|
|
|
Endpoint: endpoint.String(),
|
2019-02-14 12:37:47 +03:00
|
|
|
AdminSecret: os.Getenv("HASURA_GRAPHQL_TEST_ADMIN_SECRET"),
|
2018-07-09 16:47:38 +03:00
|
|
|
ParsedEndpoint: endpoint,
|
2018-06-29 13:02:33 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
actionType: "apply",
|
|
|
|
}
|
|
|
|
|
2019-02-14 12:37:47 +03:00
|
|
|
opts.EC.Version = version.New()
|
|
|
|
v, err := version.FetchServerVersion(opts.EC.ServerConfig.Endpoint)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("getting server version failed: %v", err)
|
|
|
|
}
|
|
|
|
opts.EC.Version.SetServerVersion(v)
|
|
|
|
|
|
|
|
err = opts.run()
|
2018-06-29 13:02:33 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed exporting metadata: %v", err)
|
|
|
|
}
|
|
|
|
}
|