@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 110 lines 3.23 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as cloudchannel from "@distilled.cloud/gcp/cloudchannel_v1";
5 import * as Effect from "effect/Effect";
6 import {
7 logLevel,
8 probeAccountName,
9 probeCustomerBody,
10 runLifecycle,
11 waitUntilPartnerCustomerGone,
12 } from "./common.ts";
13
14 const { test } = Test.make({ providers: GCP.providers() });
15
16 const probePartner = `${probeAccountName}/channelPartnerLinks/alchemy-missing`;
17
18 test.provider(
19 "getAccountsChannelPartnerLinksCustomers on a missing customer fails with a typed tag",
20 (stack) =>
21 Effect.gen(function* () {
22 yield* stack.destroy();
23
24 const error = yield* Effect.flip(
25 cloudchannel.getAccountsChannelPartnerLinksCustomers({
26 name: `${probeAccountName}/customers/alchemy-missing`,
27 }),
28 );
29 expect(error._tag).toEqual("Forbidden");
30
31 yield* stack.destroy();
32 }).pipe(logLevel),
33 {
34 tags: ["provider:gcp", "provider:gcp:cloudchannel", "live"],
35 timeout: 90_000,
36 },
37 );
38
39 test.provider.skipIf(runLifecycle)(
40 "createAccountsChannelPartnerLinksCustomers without Cloud Channel access fails with a typed entitlement error",
41 (stack) =>
42 Effect.gen(function* () {
43 yield* stack.destroy();
44
45 const error = yield* Effect.flip(
46 cloudchannel.createAccountsChannelPartnerLinksCustomers({
47 parent: probePartner,
48 body: probeCustomerBody,
49 }),
50 );
51 expect(error._tag).toEqual("Forbidden");
52
53 yield* stack.destroy();
54 }).pipe(logLevel),
55 {
56 tags: ["provider:gcp", "provider:gcp:cloudchannel", "live"],
57 timeout: 90_000,
58 },
59 );
60
61 test.provider.skipIf(!runLifecycle)(
62 "create, update, and delete a channel partner customer",
63 (stack) =>
64 Effect.gen(function* () {
65 yield* stack.destroy();
66
67 const partner = process.env.GOOGLE_CLOUDCHANNEL_PARTNER?.trim() ?? probePartner;
68
69 const created = yield* stack.deploy(
70 Effect.gen(function* () {
71 return yield* GCP.CloudChannel.ChannelPartnerLinksCustomer("Resold", {
72 parent: partner,
73 orgDisplayName: "Resold Corp",
74 });
75 }),
76 );
77
78 expect(created.name).toContain("/customers/");
79 expect(created.orgDisplayName).toEqual("Resold Corp");
80
81 const fetched = yield* cloudchannel.getAccountsChannelPartnerLinksCustomers({
82 name: created.name,
83 });
84 expect(fetched.name).toEqual(created.name);
85 expect(fetched.orgDisplayName).toEqual("Resold Corp");
86
87 const updated = yield* stack.deploy(
88 Effect.gen(function* () {
89 return yield* GCP.CloudChannel.ChannelPartnerLinksCustomer("Resold", {
90 parent: partner,
91 customerId: created.customerId,
92 orgDisplayName: "Resold Corporation",
93 domain: created.domain,
94 });
95 }),
96 );
97
98 expect(updated.name).toEqual(created.name);
99 expect(updated.orgDisplayName).toEqual("Resold Corporation");
100
101 yield* stack.destroy();
102
103 const gone = yield* waitUntilPartnerCustomerGone(created.name);
104 expect(gone).toEqual("gone");
105 }).pipe(logLevel),
106 {
107 tags: ["provider:gcp", "provider:gcp:cloudchannel", "live"],
108 timeout: 90_000,
109 },
110 );