Open History to see the last commit
1import { assert, describe, it } from "@effect/vitest";
2
3import * as GitCafeHosts from "./gitCafeHosts.ts";
4
5describe("gitCafeHosts", () => {
6 it("knows exactly the production and staging hosts", () => {
7 assert.deepStrictEqual([...GitCafeHosts.GITCAFE_HOSTS], ["git.cafe", "staging.git.cafe"]);
8 assert.isTrue(GitCafeHosts.isGitCafeHost("Git.Cafe"));
9 assert.isTrue(GitCafeHosts.isGitCafeHost("staging.git.cafe"));
10 for (const host of ["cafe", "evil.git.cafe", "git.cafe.example.com", "github.com"]) {
11 assert.isFalse(GitCafeHosts.isGitCafeHost(host), host);
12 }
13 });
14
15 it.each([
16 ["https://staging.git.cafe/team/project.git/", "staging.git.cafe"],
17 ["ssh@git.cafe:team/project.git", "git.cafe"],
18 ["ssh@git.cafe:/team/project.git", "git.cafe"],
19 ["ssh://git@git.cafe/team/project.git", "git.cafe"],
20 ["ssh://git.cafe/team/project.git", "git.cafe"],
21 ["ssh://git.cafe:2222/team/project.git", "git.cafe"],
22 ["git.cafe:team/project.git", "git.cafe"],
23 ["https://git.cafe/%74eam/project.git", "git.cafe"],
24 ["https://git.cafe/team/%70roject%2Egit", "git.cafe"],
25 ])("reads the host and repository of %s", (url, host) => {
26 assert.deepStrictEqual(GitCafeHosts.parseGitCafeRemote(url), {
27 host,
28 repository: "team/project",
29 });
30 });
31
32 it.each([
33 "https://evil.git.cafe/team/project.git",
34 "https://git.cafe/team%2Fproject.git",
35 "https://git.cafe/versecafe/ashlar.git%20",
36 "https://git.cafe/team/%E0%A4%A.git",
37 "https://git.cafe/team/nested/project.git",
38 "git.cafe://team/project.git",
39 "team/project",
40 ])("is not a GitCafe repository: %s", (url) => {
41 assert.isNull(GitCafeHosts.parseGitCafeRemote(url));
42 });
43});