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