Open History to see the last commit
1import { expect, it } from "@effect/vitest";
2
3import {
4 BUILT_IN_SOURCE_CONTROL_DRIVER_LIST,
5 sourceControlDefinitions,
6} from "./sourceControlDefinitions.ts";
7
8it("runs a driver for every host the server and clients read, in their order", () => {
9 expect(BUILT_IN_SOURCE_CONTROL_DRIVER_LIST.map((driver) => driver.definition)).toEqual(
10 sourceControlDefinitions.definitions,
11 );
12});
13
14it.each([
15 "C:/repos/project",
16 "C:\\repos\\project",
17 "/srv/git/repo.git",
18 "./team:group/repo",
19 "file:///srv/git/repo.git",
20 "hg::team/repo",
21 "codecommit::us-east-1://repo",
22])("finds no host in %s, which git does not read as SSH", (remoteUrl) => {
23 expect(sourceControlDefinitions.recognizeRemote(remoteUrl)).toBeNull();
24});
25
26it.each([
27 ["https://github.com/Acme/Web/issues/42", "github", "github.com", "acme/web", "42"],
28 [
29 "https://gitlab.acme.test/group/sub/web/-/issues/7",
30 "gitlab",
31 "gitlab.acme.test",
32 "group/sub/web",
33 "7",
34 ],
35 ["https://codeberg.org/acme/web/issues/3", "forgejo", "codeberg.org", "acme/web", "3"],
36 [
37 "https://dev.azure.com/acme/Web%20App/_workitems/edit/9",
38 "azure-devops",
39 "dev.azure.com",
40 "acme/web app",
41 "9",
42 ],
43] as const)("reads %s as an issue on its host", (url, kind, host, scope, key) => {
44 const parsed = sourceControlDefinitions.parseIssueUrl(url);
45 expect(parsed?.definition.kind).toBe(kind);
46 expect(parsed?.link).toEqual({ host, scope, key });
47});
48
49it.each([
50 "https://github.com/acme/web/pull/42",
51 "https://example.test/acme/web/issues/42",
52 "https://github.com/acme/web/issues/0",
53])("does not read %s as an issue", (url) => {
54 expect(sourceControlDefinitions.parseIssueUrl(url)).toBeNull();
55});