t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/AWS/ApiGateway/UsagePlan.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

88 lines
2.5 KiB
TypeScript

import * as AWS from "@/AWS";
import * as Provider from "@/Provider";
import * as Test from "./Test.ts";
import * as ag from "@distilled.cloud/aws/api-gateway";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
import { assertUsagePlanDeleted } from "./assertions.ts";
const { test } = Test.make({ providers: AWS.providers() });
test.provider.skipIf(!!process.env.FAST)(
"create and delete usage plan",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const plan = yield* stack.deploy(
Effect.gen(function* () {
return yield* AWS.ApiGateway.UsagePlan("AgUsagePlan", {
description: "test plan",
});
}),
);
expect(plan.id).toBeDefined();
yield* stack.destroy();
yield* assertUsagePlanDeleted(plan.id);
}),
{ tags: ["provider:aws", "provider:aws:apigateway", "live"] },
);
test.provider.skipIf(!!process.env.FAST)(
"usage plan throttle updates in place",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const plan = yield* stack.deploy(
Effect.gen(function* () {
return yield* AWS.ApiGateway.UsagePlan("AgUsagePlanThrottle", {
throttle: { burstLimit: 10, rateLimit: 100 },
});
}),
);
yield* stack.deploy(
Effect.gen(function* () {
return yield* AWS.ApiGateway.UsagePlan("AgUsagePlanThrottle", {
throttle: { burstLimit: 20, rateLimit: 200 },
});
}),
);
const remote = yield* ag.getUsagePlan({ usagePlanId: plan.id });
expect(remote.throttle?.burstLimit).toEqual(20);
expect(remote.throttle?.rateLimit).toEqual(200);
yield* stack.destroy();
yield* assertUsagePlanDeleted(plan.id);
}),
{ tags: ["provider:aws", "provider:aws:apigateway", "live"] },
);
test.provider.skipIf(!!process.env.FAST)(
"list enumerates the deployed usage plan",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const plan = yield* stack.deploy(
Effect.gen(function* () {
return yield* AWS.ApiGateway.UsagePlan("AgUsagePlanList", {
description: "list test plan",
});
}),
);
const provider = yield* Provider.findProvider(AWS.ApiGateway.UsagePlan);
const all = yield* provider.list();
expect(all.some((p) => p.id === plan.id)).toBe(true);
yield* stack.destroy();
yield* assertUsagePlanDeleted(plan.id);
}),
{ tags: ["provider:aws", "provider:aws:apigateway", "live"] },
);