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, 04:45 UTC
| 1 | import { VcsProcessExitError } from "@t3tools/contracts"; |
| 2 | import { expect, it } from "@effect/vitest"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as FileSystem from "effect/FileSystem"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost"; |
| 7 | |
| 8 | import * as GitLabCli from "./GitLabCli.ts"; |
| 9 | import * as GitLabPullRequestCli from "./GitLabPullRequestCli.ts"; |
| 10 | import * as GitLabPullRequestProvider from "./GitLabPullRequestProvider.ts"; |
| 11 | |
| 12 | it.effect("reports activity as rate limited when only the reactions endpoint is", () => |
| 13 | Effect.gen(function* () { |
| 14 | const provider = yield* GitLabPullRequestProvider.make.pipe( |
| 15 | Effect.provide( |
| 16 | GitLabPullRequestCli.layer.pipe( |
| 17 | Layer.provide(GitLabCli.layer), |
| 18 | Layer.provide( |
| 19 | TestSourceControlHost.layer({ |
| 20 | process: { |
| 21 | run: (input) => |
| 22 | input.args[1] === "graphql" |
| 23 | ? Effect.fail( |
| 24 | new VcsProcessExitError({ |
| 25 | operation: input.operation, |
| 26 | command: input.command, |
| 27 | cwd: input.cwd, |
| 28 | exitCode: 1, |
| 29 | detail: "API rate limit exceeded.", |
| 30 | failureKind: "rate-limited", |
| 31 | }), |
| 32 | ) |
| 33 | : Effect.succeed(TestSourceControlHost.processOutput("[]")), |
| 34 | }, |
| 35 | }), |
| 36 | ), |
| 37 | Layer.provide(FileSystem.layerNoop({})), |
| 38 | ), |
| 39 | ), |
| 40 | ); |
| 41 | const reference = { |
| 42 | cwd: "/repo", |
| 43 | repository: "acme/web", |
| 44 | host: "gitlab.example.test", |
| 45 | number: 1, |
| 46 | }; |
| 47 | |
| 48 | expect(yield* Effect.result(provider.getChangeRequestActivity(reference))).toMatchObject({ |
| 49 | _tag: "Failure", |
| 50 | failure: { |
| 51 | _tag: "PullRequestProviderError", |
| 52 | reason: "rate-limited", |
| 53 | cause: { _tag: "GitLabCliRateLimitError" }, |
| 54 | }, |
| 55 | }); |
| 56 | }), |
| 57 | ); |