mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-13 22:07:44 +02:00
85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
import * as GCP from "@/GCP";
|
|
import * as Test from "@/Test/Alchemy";
|
|
import * as dataplex from "@distilled.cloud/gcp/dataplex_v1";
|
|
import { expect } from "alchemy-test";
|
|
import * as Effect from "effect/Effect";
|
|
import { MinimumLogLevel } from "effect/References";
|
|
import * as Schedule from "effect/Schedule";
|
|
import { withDataplexSlot } from "./quota.ts";
|
|
|
|
const { test } = Test.make({ providers: GCP.providers() });
|
|
|
|
const logLevel = Effect.provideService(
|
|
MinimumLogLevel,
|
|
process.env.DEBUG ? "Debug" : "Info",
|
|
);
|
|
|
|
const waitUntilGone = (name: string) =>
|
|
dataplex.getProjectsLocationsEntryGroups({ name }).pipe(
|
|
Effect.as("found" as const),
|
|
Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
|
|
Effect.repeat({
|
|
schedule: Schedule.spaced("1 second"),
|
|
until: (status) => status === "gone",
|
|
times: 10,
|
|
}),
|
|
);
|
|
|
|
test.provider.skipIf(!!process.env.FAST)(
|
|
"create, update, and delete an entry group",
|
|
(stack) =>
|
|
Effect.gen(function* () {
|
|
yield* stack.destroy();
|
|
|
|
const created = yield* stack.deploy(
|
|
Effect.gen(function* () {
|
|
return yield* GCP.Dataplex.EntryGroup("Catalog", {
|
|
location: "us-central1",
|
|
displayName: "catalog a",
|
|
description: "group a",
|
|
labels: { env: "test" },
|
|
});
|
|
}),
|
|
);
|
|
|
|
expect(created.name).toContain("/entryGroups/");
|
|
expect(created.entryGroupId).toEqual(expect.any(String));
|
|
expect(created.location).toEqual("us-central1");
|
|
expect(created.displayName).toEqual("catalog a");
|
|
expect(created.description).toEqual("group a");
|
|
expect(created.labels).toMatchObject({ env: "test" });
|
|
|
|
const fetched = yield* dataplex.getProjectsLocationsEntryGroups({
|
|
name: created.name,
|
|
});
|
|
expect(fetched.name).toEqual(created.name);
|
|
expect(fetched.labels?.env).toEqual("test");
|
|
expect(
|
|
Object.keys(fetched.labels ?? {}).some((key) =>
|
|
key.startsWith("alchemy-"),
|
|
),
|
|
).toEqual(true);
|
|
|
|
const updated = yield* stack.deploy(
|
|
Effect.gen(function* () {
|
|
return yield* GCP.Dataplex.EntryGroup("Catalog", {
|
|
entryGroupId: created.entryGroupId,
|
|
location: "us-central1",
|
|
displayName: "catalog b",
|
|
description: "group b",
|
|
labels: { env: "prod", team: "data" },
|
|
});
|
|
}),
|
|
);
|
|
|
|
expect(updated.name).toEqual(created.name);
|
|
expect(updated.displayName).toEqual("catalog b");
|
|
expect(updated.description).toEqual("group b");
|
|
expect(updated.labels).toMatchObject({ env: "prod", team: "data" });
|
|
|
|
yield* stack.destroy();
|
|
const gone = yield* waitUntilGone(created.name);
|
|
expect(gone).toEqual("gone");
|
|
}).pipe(logLevel, withDataplexSlot),
|
|
{ tags: ["provider:gcp", "provider:gcp:dataplex", "live"], timeout: 900_000 },
|
|
);
|