Go · 516 bytes Raw Blame History
1 // SPDX-License-Identifier: AGPL-3.0-or-later
2
3 package policy
4
5 import "context"
6
7 // PrimeCacheForTest seeds the request cache with a (user, repo) → role
8 // entry so tests can drive Can() without a live DB. Only call from
9 // _test.go files; the export is intentionally export-tagged-as-test in
10 // its name so production callers don't reach for it.
11 func PrimeCacheForTest(ctx context.Context, userID, repoID int64, role Role) {
12 cachePut(cacheFromContext(ctx), cacheKey{actorUserID: userID, repoID: repoID}, role)
13 }
14