@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 98 lines 2.76 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 androidpublisher from "@distilled.cloud/gcp/androidpublisher_v3";
5 import * as Effect from "effect/Effect";
6 import * as Schedule from "effect/Schedule";
7 import { logLevel, packageName, probePackageName, missingTag, runLifecycle } from "./common.ts";
8
9 const { test } = Test.make({ providers: GCP.providers() });
10
11 const waitUntilGone = (appId: string, editId: string) =>
12 androidpublisher.getEdits({ packageName: appId, editId }).pipe(
13 Effect.as("found" as const),
14 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
15 Effect.repeat({
16 schedule: Schedule.spaced("1 second"),
17 until: (status) => status === "gone",
18 times: 10,
19 }),
20 );
21
22 test.provider(
23 "getEdits on a missing edit fails with a typed tag",
24 (stack) =>
25 Effect.gen(function* () {
26 yield* stack.destroy();
27
28 const error = yield* Effect.flip(
29 androidpublisher.getEdits({
30 packageName: probePackageName,
31 editId: "alchemy-missing-edit",
32 }),
33 );
34 expect(error._tag).toEqual(missingTag);
35
36 yield* stack.destroy();
37 }).pipe(logLevel),
38 {
39 tags: ["provider:gcp", "provider:gcp:androidpublisher", "live"],
40 timeout: 90_000,
41 },
42 );
43
44 test.provider.skipIf(runLifecycle)(
45 "insertEdits without Play access fails with a typed tag",
46 (stack) =>
47 Effect.gen(function* () {
48 yield* stack.destroy();
49
50 const error = yield* Effect.flip(
51 androidpublisher.insertEdits({
52 packageName: probePackageName,
53 body: {},
54 }),
55 );
56 expect(error._tag).toEqual("Forbidden");
57
58 yield* stack.destroy();
59 }).pipe(logLevel),
60 {
61 tags: ["provider:gcp", "provider:gcp:androidpublisher", "live"],
62 timeout: 90_000,
63 },
64 );
65
66 test.provider.skipIf(!runLifecycle)(
67 "create and delete an app edit",
68 (stack) =>
69 Effect.gen(function* () {
70 yield* stack.destroy();
71
72 const created = yield* stack.deploy(
73 Effect.gen(function* () {
74 return yield* GCP.AndroidPublisher.Edit("Release", {
75 packageName: packageName!,
76 });
77 }),
78 );
79
80 expect(created.editId.length).toBeGreaterThan(0);
81 expect(created.packageName).toEqual(packageName);
82
83 const fetched = yield* androidpublisher.getEdits({
84 packageName: created.packageName,
85 editId: created.editId,
86 });
87 expect(fetched.id).toEqual(created.editId);
88
89 yield* stack.destroy();
90
91 const gone = yield* waitUntilGone(created.packageName, created.editId);
92 expect(gone).toEqual("gone");
93 }).pipe(logLevel),
94 {
95 tags: ["provider:gcp", "provider:gcp:androidpublisher", "live"],
96 timeout: 90_000,
97 },
98 );