History

feat(source-control): add Bitbucket & Azure Devops providers (#2473)

Julius Marminge committed 6 months agov0.0.22-nightly.20260504.196

Commit 91a03e01 parent d501ebe59 files · +5834 −2327Browse files

Showing the changes to apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts (1 of 59 files). Show all

Unified · Split

apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts+48−9
@@ -1,11 +1,16 @@
1import { assert, it } from "@effect/vitest";1import { assert, it } from "@effect/vitest";
2import * as NodeServices from "@effect/platform-node/NodeServices";
2import { DateTime, Effect, Layer, Option } from "effect";3import { DateTime, Effect, Layer, Option } from "effect";
3 4
4import { GitHubCli } from "./GitHubCli.ts";5import { ServerConfig } from "../config.ts";
5import { GitLabCli } from "./GitLabCli.ts";6import type * as VcsDriver from "../vcs/VcsDriver.ts";
7import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
8import * as VcsProcess from "../vcs/VcsProcess.ts";
9import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
10import * as BitbucketApi from "./BitbucketApi.ts";
11import * as GitHubCli from "./GitHubCli.ts";
12import * as GitLabCli from "./GitLabCli.ts";
6import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";13import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
7import { VcsDriverRegistry } from "../vcs/VcsDriverRegistry.ts";
8import type { VcsDriverShape } from "../vcs/VcsDriver.ts";
9 14
10const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");15const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
11 16
@@ -29,10 +34,10 @@ function makeRegistry(input: { · 17 unmodified lines
29 expiresAt: Option.none(),34 expiresAt: Option.none(),
30 },35 },
31 }),36 }),
32 } satisfies Partial<VcsDriverShape>;37 } satisfies Partial<VcsDriver.VcsDriverShape>;
33 38
34 const registryLayer = Layer.mock(VcsDriverRegistry)({39 const registryLayer = Layer.mock(VcsDriverRegistry.VcsDriverRegistry)({
35 get: () => Effect.succeed(driver as unknown as VcsDriverShape),40 get: () => Effect.succeed(driver as unknown as VcsDriver.VcsDriverShape),
36 resolve: () =>41 resolve: () =>
37 Effect.succeed({42 Effect.succeed({
38 kind: "git",43 kind: "git",
@@ -46,13 +51,23 @@ function makeRegistry(input: { · 7 unmodified lines
46 expiresAt: Option.none(),51 expiresAt: Option.none(),
47 },52 },
48 },53 },
49 driver: driver as unknown as VcsDriverShape,54 driver: driver as unknown as VcsDriver.VcsDriverShape,
50 }),55 }),
51 });56 });
52 57
53 return SourceControlProviderRegistry.make().pipe(58 return SourceControlProviderRegistry.make().pipe(
54 Effect.provide(59 Effect.provide(
55 Layer.mergeAll(registryLayer, Layer.mock(GitHubCli)({}), Layer.mock(GitLabCli)({})),60 Layer.mergeAll(
61 registryLayer,
62 Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
63 Layer.mock(BitbucketApi.BitbucketApi)({}),
64 Layer.mock(GitHubCli.GitHubCli)({}),
65 Layer.mock(GitLabCli.GitLabCli)({}),
66 Layer.mock(VcsProcess.VcsProcess)({}),
67 ServerConfig.layerTest(process.cwd(), { prefix: "t3-source-control-registry-test-" }).pipe(
68 Layer.provide(NodeServices.layer),
69 ),
70 ),
56 ),71 ),
57 );72 );
58}73}
@@ -93,6 +108,30 @@ it.effect("routes GitLab remotes to the GitLab provider", () => · 34 unmodified lines
93 }),108 }),
94);109);
95 110
111it.effect("routes Bitbucket remotes to the Bitbucket provider", () =>
112 Effect.gen(function* () {
113 const registry = yield* makeRegistry({
114 remotes: [{ name: "origin", url: "git@bitbucket.org:pingdotgg/t3code.git" }],
115 });
116
117 const provider = yield* registry.resolve({ cwd: "/repo" });
118
119 assert.strictEqual(provider.kind, "bitbucket");
120 }),
121);
122
123it.effect("routes Azure DevOps remotes to the Azure DevOps provider", () =>
124 Effect.gen(function* () {
125 const registry = yield* makeRegistry({
126 remotes: [{ name: "origin", url: "https://dev.azure.com/acme/project/_git/repo" }],
127 });
128
129 const provider = yield* registry.resolve({ cwd: "/repo" });
130
131 assert.strictEqual(provider.kind, "azure-devops");
132 }),
133);
134
96it.effect("falls back to a non-origin remote when origin is not configured", () =>135it.effect("falls back to a non-origin remote when origin is not configured", () =>
97 Effect.gen(function* () {136 Effect.gen(function* () {
98 const registry = yield* makeRegistry({137 const registry = yield* makeRegistry({

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t