mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-14 14:27:45 +02:00
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import * as GCP from "@/GCP";
|
|
import * as Test from "@/Test/Alchemy";
|
|
import * as logging from "@distilled.cloud/gcp/logging_v2";
|
|
import { expect } from "alchemy-test";
|
|
import * as Effect from "effect/Effect";
|
|
import { MinimumLogLevel } from "effect/References";
|
|
import * as Schedule from "effect/Schedule";
|
|
import { GcpEnvironment } from "@/GCP/Environment";
|
|
|
|
const { test } = Test.make({ providers: GCP.providers() });
|
|
|
|
const logLevel = Effect.provideService(
|
|
MinimumLogLevel,
|
|
process.env.DEBUG ? "Debug" : "Info",
|
|
);
|
|
|
|
const waitUntilGone = (name: string) =>
|
|
logging.getProjectsLocationsBucketsLinks({ name }).pipe(
|
|
Effect.map((link) =>
|
|
link.lifecycleState === "DELETE_REQUESTED"
|
|
? ("gone" as const)
|
|
: ("found" as const),
|
|
),
|
|
Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
|
|
Effect.repeat({
|
|
schedule: Schedule.spaced("2 seconds"),
|
|
until: (status) => status === "gone",
|
|
times: 10,
|
|
}),
|
|
);
|
|
|
|
test.provider.skipIf(!!process.env.FAST)(
|
|
"create and delete a logging bucket link",
|
|
(stack) =>
|
|
Effect.gen(function* () {
|
|
const { project } = yield* GcpEnvironment.current;
|
|
|
|
yield* stack.destroy();
|
|
|
|
const created = yield* stack.deploy(
|
|
Effect.gen(function* () {
|
|
const bucket = yield* GCP.Logging.LogBucket("AppLogs", {
|
|
analyticsEnabled: true,
|
|
description: "analytics parent",
|
|
});
|
|
const link = yield* GCP.Logging.BucketsLink("Analytics", {
|
|
bucket: bucket.name,
|
|
description: "bigquery analytics",
|
|
});
|
|
return { bucket, link };
|
|
}),
|
|
);
|
|
|
|
expect(created.link.linkId).toEqual(expect.any(String));
|
|
expect(created.link.linkId).toMatch(/^[a-z][a-z0-9_]*$/);
|
|
expect(created.link.bucket).toEqual(created.bucket.name);
|
|
expect(created.link.project).toEqual(project);
|
|
expect(created.link.location).toEqual("global");
|
|
expect(created.link.name).toEqual(
|
|
`${created.bucket.name}/links/${created.link.linkId}`,
|
|
);
|
|
expect(created.link.description).toEqual("bigquery analytics");
|
|
expect(created.link.lifecycleState).toEqual("ACTIVE");
|
|
|
|
const fetched = yield* logging.getProjectsLocationsBucketsLinks({
|
|
name: created.link.name,
|
|
});
|
|
expect(fetched.name).toEqual(created.link.name);
|
|
expect(fetched.lifecycleState).toEqual("ACTIVE");
|
|
expect(fetched.description).toContain("alchemy-id=");
|
|
expect(fetched.description).toContain("bigquery analytics");
|
|
|
|
yield* stack.destroy();
|
|
|
|
const gone = yield* waitUntilGone(created.link.name);
|
|
expect(gone).toEqual("gone");
|
|
}).pipe(logLevel),
|
|
{ tags: ["provider:gcp", "provider:gcp:logging", "live"], timeout: 180_000 },
|
|
);
|