2018-06-27 15:04:09 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/briandowns/spinner"
|
|
|
|
"github.com/hasura/graphql-engine/cli"
|
2018-06-29 13:02:33 +03:00
|
|
|
"github.com/sirupsen/logrus/hooks/test"
|
2018-06-27 15:04:09 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestConsoleCmd(t *testing.T) {
|
2018-06-29 13:02:33 +03:00
|
|
|
logger, _ := test.NewNullLogger()
|
2018-06-27 15:04:09 +03:00
|
|
|
opts := &consoleOptions{
|
|
|
|
EC: &cli.ExecutionContext{
|
2018-06-29 13:02:33 +03:00
|
|
|
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
|
|
|
|
}
|