45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
package api_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
api "dappco.re/go/core/api"
|
|
)
|
|
|
|
func TestEngine_GraphQLConfig_Good_SnapshotsCurrentSettings(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
|
|
e, err := api.New(
|
|
api.WithGraphQL(newTestSchema(), api.WithPlayground(), api.WithGraphQLPath(" /gql/ ")),
|
|
)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
cfg := e.GraphQLConfig()
|
|
if !cfg.Enabled {
|
|
t.Fatal("expected GraphQL to be enabled")
|
|
}
|
|
if cfg.Path != "/gql" {
|
|
t.Fatalf("expected GraphQL path /gql, got %q", cfg.Path)
|
|
}
|
|
if !cfg.Playground {
|
|
t.Fatal("expected GraphQL playground to be enabled")
|
|
}
|
|
if cfg.PlaygroundPath != "/gql/playground" {
|
|
t.Fatalf("expected GraphQL playground path /gql/playground, got %q", cfg.PlaygroundPath)
|
|
}
|
|
}
|
|
|
|
func TestEngine_GraphQLConfig_Good_EmptyOnNilEngine(t *testing.T) {
|
|
var e *api.Engine
|
|
|
|
cfg := e.GraphQLConfig()
|
|
if cfg.Enabled || cfg.Path != "" || cfg.Playground || cfg.PlaygroundPath != "" {
|
|
t.Fatalf("expected zero-value GraphQL config, got %+v", cfg)
|
|
}
|
|
}
|