Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

gitCafeHosts.test.ts

34 lines1.2 KB

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