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