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

Function providerLayer

apps/cloud/src/auth/mirror-feeders.node.test.ts:1125–1167  ·  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

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