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
| 1 | import * as Railway from "@alchemy.run/railway"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import { MinimumLogLevel } from "effect/References"; |
| 6 | import { suitePartition } from "./suiteProject.ts"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: Railway.providers() }); |
| 9 | |
| 10 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 11 | |
| 12 | test.provider( |
| 13 | "list workspace audit logs", |
| 14 | (stack) => |
| 15 | Effect.gen(function* () { |
| 16 | yield* stack.destroy(); |
| 17 | |
| 18 | const types = yield* Railway.listAuditLogEventTypes(); |
| 19 | expect(Array.isArray(types)).toEqual(true); |
| 20 | for (const item of types) { |
| 21 | expect(item.eventType).toEqual(expect.any(String)); |
| 22 | expect(item.eventType.length).toBeGreaterThan(0); |
| 23 | expect(item.description).toEqual(expect.any(String)); |
| 24 | } |
| 25 | |
| 26 | const logs = yield* Railway.listAuditLogs({ first: 10 }); |
| 27 | expect(Array.isArray(logs)).toEqual(true); |
| 28 | for (const log of logs) { |
| 29 | expect(log.id).toEqual(expect.any(String)); |
| 30 | expect(log.id.length).toBeGreaterThan(0); |
| 31 | expect(log.eventType).toEqual(expect.any(String)); |
| 32 | expect(log.eventType.length).toBeGreaterThan(0); |
| 33 | expect(log.createdAt).toEqual(expect.any(String)); |
| 34 | } |
| 35 | |
| 36 | const created = yield* stack.deploy( |
| 37 | Effect.gen(function* () { |
| 38 | const { project, environment } = yield* suitePartition; |
| 39 | return { project, environment }; |
| 40 | }), |
| 41 | ); |
| 42 | |
| 43 | const projectLogs = yield* Railway.listAuditLogs({ |
| 44 | project: created.project, |
| 45 | environment: created.environment, |
| 46 | first: 10, |
| 47 | }); |
| 48 | expect(Array.isArray(projectLogs)).toEqual(true); |
| 49 | expect( |
| 50 | projectLogs.every( |
| 51 | (log) => log.projectId === undefined || log.projectId === created.project.projectId, |
| 52 | ), |
| 53 | ).toEqual(true); |
| 54 | |
| 55 | const first = logs[0] ?? projectLogs[0]; |
| 56 | if (first !== undefined) { |
| 57 | const fetched = yield* Railway.getAuditLog({ id: first.id }); |
| 58 | expect(fetched.id).toEqual(first.id); |
| 59 | expect(fetched.eventType).toEqual(first.eventType); |
| 60 | } |
| 61 | |
| 62 | yield* stack.destroy(); |
| 63 | }).pipe(logLevel), |
| 64 | { |
| 65 | tags: [ |
| 66 | "provider:railway", |
| 67 | "provider:railway:project", |
| 68 | "provider:railway:projectenvironment", |
| 69 | "live", |
| 70 | ], |
| 71 | timeout: 120_000, |
| 72 | }, |
| 73 | ); |