The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Stripe from "@alchemy.run/stripe"; |
| 2 | import { Credentials } from "@alchemy.run/stripe/Credentials"; |
| 3 | import { expect, it } from "@alchemy.run/test"; |
| 4 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 5 | import { AlchemyContext } from "alchemy/AlchemyContext"; |
| 6 | import { AuthProvidersLive } from "alchemy/Auth/AuthProvider"; |
| 7 | import * as Interaction from "alchemy/Interaction"; |
| 8 | import { Stack } from "alchemy/Stack"; |
| 9 | import { Stage } from "alchemy/Stage"; |
| 10 | import * as ConfigProvider from "effect/ConfigProvider"; |
| 11 | import * as Effect from "effect/Effect"; |
| 12 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 13 | import * as Layer from "effect/Layer"; |
| 14 | import * as Result from "effect/Result"; |
| 15 | import { v4 as uuidv4 } from "uuid"; |
| 16 | |
| 17 | it.live( |
| 18 | "resolving Stripe credentials rejects an unknown explicit profile", |
| 19 | () => |
| 20 | Effect.gen(function* () { |
| 21 | const result = yield* Effect.result( |
| 22 | Effect.sandbox( |
| 23 | Effect.gen(function* () { |
| 24 | return yield* yield* Credentials; |
| 25 | }).pipe(Effect.provide(Stripe.providers())), |
| 26 | ), |
| 27 | ); |
| 28 | expect(Result.isFailure(result)).toBe(true); |
| 29 | if (Result.isFailure(result)) { |
| 30 | expect(String(result.failure)).toContain("does not exist"); |
| 31 | expect(String(result.failure)).toContain("alchemy profile create"); |
| 32 | } |
| 33 | }).pipe( |
| 34 | Effect.provide( |
| 35 | Layer.mergeAll( |
| 36 | AuthProvidersLive, |
| 37 | Layer.succeed(Stage, "test"), |
| 38 | Layer.succeed(Stack, { |
| 39 | name: "test", |
| 40 | stage: "test", |
| 41 | resources: {}, |
| 42 | bindings: {}, |
| 43 | actions: {}, |
| 44 | }), |
| 45 | Layer.succeed(AlchemyContext, { dev: false, adopt: false, dotAlchemy: ".alchemy" }), |
| 46 | Layer.succeed( |
| 47 | ConfigProvider.ConfigProvider, |
| 48 | ConfigProvider.fromUnknown({ ALCHEMY_PROFILE: `non-existent-${uuidv4()}` }), |
| 49 | ), |
| 50 | NodeServices.layer, |
| 51 | FetchHttpClient.layer, |
| 52 | ), |
| 53 | ), |
| 54 | Effect.provide(Interaction.layerNonInteractive()), |
| 55 | ), |
| 56 | { tags: ["unit", "provider:stripe", "local"] }, |
| 57 | ); |