-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphql_config_test.go
More file actions
45 lines (36 loc) · 1.06 KB
/
graphql_config_test.go
File metadata and controls
45 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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)
}
}