graphql-engine/cli/commands/console_test.go

43 lines
901 B
Go
Raw Normal View History

2018-06-27 15:04:09 +03:00
package commands
import (
"testing"
"time"
"github.com/briandowns/spinner"
"github.com/hasura/graphql-engine/cli"
"github.com/sirupsen/logrus/hooks/test"
2018-06-27 15:04:09 +03:00
)
func TestConsoleCmd(t *testing.T) {
logger, _ := test.NewNullLogger()
2018-06-27 15:04:09 +03:00
opts := &consoleOptions{
EC: &cli.ExecutionContext{
Logger: logger,
2018-06-27 15:04:09 +03:00
Spinner: spinner.New(spinner.CharSets[7], 100*time.Millisecond),
Config: &cli.HasuraGraphQLConfig{
Endpoint: "http://localhost:8080",
AccessKey: "",
},
},
APIPort: "9693",
ConsolePort: "9695",
Address: "localhost",
DontOpenBrowser: true,
}
go func() {
t.Log("waiting for console to start")
for opts.WG == nil {
time.Sleep(1 * time.Second)
}
opts.WG.Done()
opts.WG.Done()
}()
2018-06-28 11:44:01 +03:00
err := opts.run()
2018-06-27 15:04:09 +03:00
if err != nil {
t.Fatalf("failed running console: %v", err)
}
// TODO: (shahidhk) curl the console endpoint for 200 response
}