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

Function providerLayer

apps/cloud/src/auth/mirror-feeders.node.test.ts:1130–1172  ·  view source on GitHub ↗
(
    org: string,
    deleted: string[],
    options: {
      readonly workos?: Partial<WorkOSClientService>;
      readonly autumn?: Layer.Layer<AutumnService>;
    } = {},
  )

Source from the content-addressed store, hash-verified

1128 * body so the postgres socket outlives the provider call under test.
1129 */
1130 const providerLayer = (
1131 org: string,
1132 deleted: string[],
1133 options: {
1134 readonly workos?: Partial<WorkOSClientService>;
1135 readonly autumn?: Layer.Layer<AutumnService>;
1136 } = {},
1137 ) => {
1138 const workos = stubWorkOS({
1139 ...options.workos,
1140 deleteOrgMembership: (membershipId) =>
1141 Effect.sync(() => {
1142 deleted.push(membershipId);
1143 }),
1144 updateOrgMembershipRole: (membershipId, roleSlug) =>
1145 Effect.succeed(
1146 workosMembership(TARGET, org, {
1147 id: membershipId,
1148 role: { slug: roleSlug },
1149 updatedAt: T2,
1150 }) as never,
1151 ),
1152 });
1153 // The test database serves ONE connection at a time, so the seed, the
1154 // provider, and the directory read all share this layer's socket.
1155 const stores = Layer.mergeAll(
1156 UserStoreService.Live,
1157 WorkOsMirror.Live,
1158 cloudMemberDirectoryLayer,
1159 );
1160 return workosAccountProvider.pipe(
1161 Layer.provide(
1162 Layer.mergeAll(
1163 workos,
1164 stubApiKeys,
1165 options.autumn ?? stubAutumn,
1166 Layer.succeed(AccountCaller)({ session: session(ADMIN), adminVerified: true }),
1167 ),
1168 ),
1169 Layer.provideMerge(stores),
1170 Layer.provide(DbService.Live),
1171 );
1172 };
1173
1174 // ADMIN as the org's admin and TARGET as an existing member of `org`,
1175 // seeded through the live mirror — the rows the provider's membership reads

Callers 1

Calls 5

pushMethod · 0.80
stubWorkOSFunction · 0.70
workosMembershipFunction · 0.70
sessionFunction · 0.70
syncMethod · 0.65

Tested by

no test coverage detected