MCPcopy
hub / github.com/dosco/graphjin / TestGraphQLRoleQueryMatchesConfiguredRole

Function TestGraphQLRoleQueryMatchesConfiguredRole

core/role_query_graphql_test.go:14–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestGraphQLRoleQueryMatchesConfiguredRole(t *testing.T) {
15 db := newGraphQLRoleTestDB(t)
16 defer db.Close() //nolint:errcheck
17
18 conf := graphQLRoleTestConfig()
19 gj, err := core.NewGraphJin(conf, db)
20 if err != nil {
21 t.Fatal(err)
22 }
23 defer gj.Close()
24
25 ctx := context.WithValue(context.Background(), core.UserIDKey, 1)
26 res, err := gj.GraphQL(ctx, `{ users(id: 1) { id email } }`, nil, nil)
27 if err != nil {
28 t.Fatal(err)
29 }
30 if got := res.Role(); got != "admin" {
31 t.Fatalf("role = %q, want admin", got)
32 }
33}
34
35func TestGraphQLRoleQueryDefaultsToUser(t *testing.T) {
36 db := newGraphQLRoleTestDB(t)

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
GraphQLMethod · 0.95
newGraphQLRoleTestDBFunction · 0.85
graphQLRoleTestConfigFunction · 0.85
RoleMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected