| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import { expect } from "alchemy-test"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as pathe from "pathe"; |
| 6 | import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts"; |
| 7 | import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts"; |
| 8 | import { dockerAvailable } from "../bindingHost.ts"; |
| 9 | import { |
| 10 | assertSiteGone, |
| 11 | cloudRunUrl, |
| 12 | liveOptions, |
| 13 | logLevel, |
| 14 | serviceIdentity, |
| 15 | tempRoot, |
| 16 | } from "./site.ts"; |
| 17 | |
| 18 | const { test } = Test.make({ providers: GCP.providers() }); |
| 19 | |
| 20 | const fixtureDir = pathe.resolve( |
| 21 | import.meta.dirname, |
| 22 | "../../../../../examples/cloudflare-website-vocs", |
| 23 | ); |
| 24 | const fixtureEntries = [ |
| 25 | "package.json", |
| 26 | "public", |
| 27 | "src", |
| 28 | "tsconfig.json", |
| 29 | "vocs.config.ts", |
| 30 | ]; |
| 31 | |
| 32 | test.provider.skipIf(!dockerAvailable)( |
| 33 | "Vocs: deploy, GET /, destroy, gone", |
| 34 | (stack) => |
| 35 | Effect.gen(function* () { |
| 36 | yield* stack.destroy(); |
| 37 | |
| 38 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 39 | prefix: "alchemy-vocs-gcp-", |
| 40 | tempRoot, |
| 41 | entries: fixtureEntries, |
| 42 | }); |
| 43 | |
| 44 | const deployed = yield* stack.deploy( |
| 45 | Effect.gen(function* () { |
| 46 | const site = yield* GCP.Website.Vocs("Web", { |
| 47 | rootDir, |
| 48 | memo: { |
| 49 | include: [ |
| 50 | "src/**", |
| 51 | "public/**", |
| 52 | "package.json", |
| 53 | "tsconfig.json", |
| 54 | "vocs.config.ts", |
| 55 | ], |
| 56 | }, |
| 57 | }); |
| 58 | return { site }; |
| 59 | }), |
| 60 | ); |
| 61 | |
| 62 | const url = deployed.site.url as string; |
| 63 | expect(url).toMatch(cloudRunUrl); |
| 64 | expect(deployed.site.service).toBeDefined(); |
| 65 | const service = serviceIdentity(deployed.site.service!); |
| 66 | |
| 67 | yield* expectUrlContains(`${url}/`, "Alchemy with Vocs", { |
| 68 | timeout: "180 seconds", |
| 69 | label: "Vocs /", |
| 70 | }); |
| 71 | |
| 72 | yield* stack.destroy(); |
| 73 | yield* assertSiteGone(service); |
| 74 | }).pipe(logLevel), |
| 75 | liveOptions(900_000), |
| 76 | ); |