| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import * as artifactregistry from "@distilled.cloud/gcp/artifactregistry_v1"; |
| 4 | import * as Region from "@distilled.cloud/gcp/Region"; |
| 5 | import { expect } from "alchemy-test"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import * as Layer from "effect/Layer"; |
| 8 | |
| 9 | const { test } = Test.make({ |
| 10 | providers: GCP.providers().pipe( |
| 11 | Layer.provideMerge(GCP.Region("us-east4")), |
| 12 | Layer.provideMerge(GCP.RegionalEndpoints("prefer")), |
| 13 | ), |
| 14 | }); |
| 15 | |
| 16 | test.provider( |
| 17 | "GCP.RegionalEndpoints('prefer') on the providers layer deploys through the regional endpoint", |
| 18 | (stack) => |
| 19 | Effect.gen(function* () { |
| 20 | yield* stack.destroy(); |
| 21 | const repo = yield* stack.deploy( |
| 22 | GCP.ArtifactRegistry.Repository("PreferRepo", { format: "DOCKER" }), |
| 23 | ); |
| 24 | expect(repo.name).toContain("/locations/us-east4/"); |
| 25 | // The same resource is reachable through the regional host directly. |
| 26 | const live = yield* artifactregistry |
| 27 | .getProjectsLocationsRepositories({ name: repo.name }) |
| 28 | .pipe(Effect.provide(Region.regionalEndpoints("prefer"))); |
| 29 | expect(live.name).toEqual(repo.name); |
| 30 | yield* stack.destroy(); |
| 31 | }), |
| 32 | { |
| 33 | tags: ["provider:gcp", "provider:gcp:artifactregistry", "live"], |
| 34 | timeout: 180_000, |
| 35 | }, |
| 36 | ); |