(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestGraphQLRoleQueryMultipleRowsError(t *testing.T) { |
| 69 | db := newGraphQLRoleTestDB(t) |
| 70 | defer db.Close() //nolint:errcheck |
| 71 | |
| 72 | conf := &core.Config{ |
| 73 | DBType: "sqlite", |
| 74 | DisableAllowList: true, |
| 75 | RolesQuery: `query { |
| 76 | users(where: { id: { gt: $user_id } }) { |
| 77 | userid: id |
| 78 | } |
| 79 | }`, |
| 80 | Roles: []core.Role{ |
| 81 | {Name: "admin", Match: "userid = 1"}, |
| 82 | }, |
| 83 | } |
| 84 | |
| 85 | gj, err := core.NewGraphJin(conf, db) |
| 86 | if err != nil { |
| 87 | t.Fatal(err) |
| 88 | } |
| 89 | defer gj.Close() |
| 90 | |
| 91 | ctx := context.WithValue(context.Background(), core.UserIDKey, 0) |
| 92 | _, err = gj.GraphQL(ctx, `{ users(id: 1) { id } }`, nil, nil) |
| 93 | if err == nil { |
| 94 | t.Fatal("GraphQL() expected multiple rows error") |
| 95 | } |
| 96 | if !strings.Contains(err.Error(), "roles_query returned multiple rows") { |
| 97 | t.Fatalf("GraphQL() error = %v, want multiple rows roles_query error", err) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func TestGraphQLRoleQueryMalformedMatchErrorsAtInit(t *testing.T) { |
| 102 | db := newGraphQLRoleTestDB(t) |
nothing calls this directly
no test coverage detected