(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func 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 | |
| 35 | func TestGraphQLRoleQueryDefaultsToUser(t *testing.T) { |
| 36 | db := newGraphQLRoleTestDB(t) |
nothing calls this directly
no test coverage detected