mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-11 12:51:15 +02:00
67 lines
2.4 KiB
TypeScript
67 lines
2.4 KiB
TypeScript
import { AlchemyContext } from "@/AlchemyContext.ts";
|
|
import { ArtifactStore, createArtifactStore } from "@/Artifacts.ts";
|
|
import { AuthProviders } from "@/Auth/AuthProvider.ts";
|
|
import { ProfileStoreLive } from "@/Auth/Profile.ts";
|
|
import * as AWS from "@/AWS";
|
|
import { AWSEnvironment } from "@/AWS/Environment.ts";
|
|
import { Stack } from "@/Stack.ts";
|
|
import { Stage } from "@/Stage.ts";
|
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
import { expect, it } from "alchemy-test";
|
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
import * as Effect from "effect/Effect";
|
|
import * as Layer from "effect/Layer";
|
|
import * as Result from "effect/Result";
|
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
import { v4 as uuidv4 } from "uuid";
|
|
|
|
it.live(
|
|
"building the AWS provider layers rejects an unknown explicit profile",
|
|
() =>
|
|
Effect.gen(function* () {
|
|
// AWSEnvironment is constructed lazily so `alchemy dev` can build
|
|
// provider layers without credentials. The unknown-profile rejection
|
|
// surfaces on first use, not at `Layer.build`.
|
|
const result = yield* Effect.result(
|
|
Effect.sandbox(
|
|
AWSEnvironment.current.pipe(Effect.provide(AWS.providers())),
|
|
),
|
|
);
|
|
expect(Result.isFailure(result)).toBe(true);
|
|
if (Result.isFailure(result)) {
|
|
expect(String(result.failure)).toContain("does not exist");
|
|
expect(String(result.failure)).toContain("alchemy profile create");
|
|
}
|
|
}).pipe(
|
|
Effect.provide(
|
|
Layer.mergeAll(
|
|
Layer.succeed(AuthProviders, {}),
|
|
Layer.sync(ArtifactStore, createArtifactStore),
|
|
Layer.succeed(Stage, "test"),
|
|
Layer.succeed(Stack, {
|
|
name: "test",
|
|
stage: "test",
|
|
resources: {},
|
|
bindings: {},
|
|
actions: {},
|
|
}),
|
|
Layer.succeed(AlchemyContext, {
|
|
dev: false,
|
|
adopt: false,
|
|
dotAlchemy: ".alchemy",
|
|
}),
|
|
ConfigProvider.layer(
|
|
ConfigProvider.fromUnknown({
|
|
ALCHEMY_PROFILE: `non-existent-${uuidv4()}`,
|
|
}),
|
|
),
|
|
ProfileStoreLive,
|
|
).pipe(
|
|
Layer.provideMerge(
|
|
Layer.mergeAll(NodeServices.layer, FetchHttpClient.layer),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
{ tags: ["unit", "provider:aws", "local"] },
|
|
);
|