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@git.cafe/team/project.git", "git.cafe"],
19 ])("reads the host and repository of %s", (url, host) => {
20 assert.deepStrictEqual(GitCafeHosts.parseGitCafeRemote(url), {
21 host,
22 repository: "team/project",
23 });
24 });
25
26 it.each([
27 "https://evil.git.cafe/team/project.git",
28 "https://git.cafe/team/nested/project.git",
29 "team/project",
30 ])("is not a GitCafe repository: %s", (url) => {
31 assert.isNull(GitCafeHosts.parseGitCafeRemote(url));
32 });
33});