mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
ca7d8b3df5
The word "reset" is little ambiguous (reset to scratch or reset to last known consistent state). metadata reset clears the all the metadata to mimic a freshly installed hasura instance. This actually invokes the clear_metadata API in the backend and hence should also be called metadata clear for perfect clarity. All references to metadata reset should be changed to metadata clear.
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"net/url"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/briandowns/spinner"
|
|
"github.com/hasura/graphql-engine/cli"
|
|
"github.com/hasura/graphql-engine/cli/version"
|
|
"github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func testMetadataReset(t *testing.T, metadataFile string, endpoint *url.URL) {
|
|
logger, _ := test.NewNullLogger()
|
|
opts := &metadataClearOptions{
|
|
EC: &cli.ExecutionContext{
|
|
Logger: logger,
|
|
Spinner: spinner.New(spinner.CharSets[7], 100*time.Millisecond),
|
|
MetadataFile: []string{metadataFile},
|
|
ServerConfig: &cli.ServerConfig{
|
|
Endpoint: endpoint.String(),
|
|
AdminSecret: os.Getenv("HASURA_GRAPHQL_TEST_ADMIN_SECRET"),
|
|
ParsedEndpoint: endpoint,
|
|
},
|
|
},
|
|
actionType: "clear",
|
|
}
|
|
|
|
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()
|
|
if err != nil {
|
|
t.Fatalf("failed exporting metadata: %v", err)
|
|
}
|
|
}
|