MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / seed

Function seed

packages/core/api/src/admin/admin-users.test.ts:163–200  ·  view source on GitHub ↗
(db: SqliteTestFumaDb)

Source from the content-addressed store, hash-verified

161/** Two users with connections under tenant A, plus a whole separate tenant B
162 * that A's admin plane must never see. */
163const seed = (db: SqliteTestFumaDb): Effect.Effect<void> =>
164 Effect.gen(function* () {
165 // `touchSubject` keeps a process-local memory of principals it already
166 // filed, so a second seed against a FRESH database would be skipped as a
167 // repeat sighting and leave the table empty. Each seed is a new world.
168 resetSubjectTouchCache();
169
170 yield* touchSubject(db.db, { tenant: TENANT_A, externalId: USER_A1 });
171 yield* touchSubject(db.db, { tenant: TENANT_A, externalId: USER_A2 });
172 yield* touchSubject(db.db, { tenant: TENANT_B, externalId: USER_B1 });
173
174 yield* insertConnection(db, {
175 rowId: "c-a1-gh",
176 tenant: TENANT_A,
177 owner: "user",
178 subject: USER_A1,
179 integration: "github",
180 name: "personal",
181 oauthScope: "repo read:user",
182 });
183 yield* insertConnection(db, {
184 rowId: "c-a2-linear",
185 tenant: TENANT_A,
186 owner: "user",
187 subject: USER_A2,
188 integration: "linear",
189 name: "work",
190 });
191 yield* insertConnection(db, {
192 rowId: "c-b1-gh",
193 tenant: TENANT_B,
194 owner: "user",
195 subject: USER_B1,
196 integration: "github",
197 name: "b-secret",
198 oauthScope: "admin:org",
199 });
200 });
201
202const platformExecutorFor = (db: SqliteTestFumaDb, tenant: string): Effect.Effect<Executor> =>
203 createExecutor({

Callers 1

Calls 3

resetSubjectTouchCacheFunction · 0.85
touchSubjectFunction · 0.85
insertConnectionFunction · 0.70

Tested by

no test coverage detected