feat: scaffold CLI and minimal issue list (task 0001)
Tracer bullet for gitea-axi: runnable npm package on axi-sdk-js with gitea-js as the sole HTTP layer, ESM on Node 20+. - issue list with --state/--limit, default fields, count line from X-Total-Count, type=issues guard, explicit empty state, and next-step suggestions - repo context detection from the git origin remote (SSH/scp/HTTPS), tea credential discovery with the three-way login-matching split, and -R/--repo and --login overrides (flag > env > auto) - token retrieval via tea login helper get: tea's login list JSON carries no token (ADR 0001 amended) - full AxiError classification table with path-based 404 split, TOON errors on stdout, exit codes 0/1/2 - test mode (GITEA_AXI_API_URL/TOKEN/REPO) suppressing subprocesses, fixture server, and vitest suites driving the CLI seam (50 tests)
This commit is contained in:
53
test/git.test.ts
Normal file
53
test/git.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseRemoteUrl } from "../src/git.js";
|
||||
|
||||
describe("parseRemoteUrl", () => {
|
||||
it("parses HTTPS remotes with and without .git", () => {
|
||||
expect(parseRemoteUrl("https://git.example.com/owner/repo.git")).toEqual({
|
||||
host: "git.example.com",
|
||||
owner: "owner",
|
||||
name: "repo",
|
||||
});
|
||||
expect(parseRemoteUrl("https://git.example.com/owner/repo")).toEqual({
|
||||
host: "git.example.com",
|
||||
owner: "owner",
|
||||
name: "repo",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses HTTP remotes with a port", () => {
|
||||
expect(parseRemoteUrl("http://git.example.com:3000/owner/repo.git")).toEqual({
|
||||
host: "git.example.com",
|
||||
owner: "owner",
|
||||
name: "repo",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses scp-form SSH remotes", () => {
|
||||
expect(parseRemoteUrl("git@git.example.com:owner/repo.git")).toEqual({
|
||||
host: "git.example.com",
|
||||
owner: "owner",
|
||||
name: "repo",
|
||||
});
|
||||
expect(parseRemoteUrl("git.example.com:owner/repo")).toEqual({
|
||||
host: "git.example.com",
|
||||
owner: "owner",
|
||||
name: "repo",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses ssh:// remotes with a port", () => {
|
||||
expect(parseRemoteUrl("ssh://git@git.example.com:2222/owner/repo.git")).toEqual({
|
||||
host: "git.example.com",
|
||||
owner: "owner",
|
||||
name: "repo",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects URLs without an owner/name path", () => {
|
||||
expect(parseRemoteUrl("https://git.example.com/owner")).toBeNull();
|
||||
expect(parseRemoteUrl("https://git.example.com/a/b/c")).toBeNull();
|
||||
expect(parseRemoteUrl("not a url")).toBeNull();
|
||||
expect(parseRemoteUrl("/local/path/repo.git")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user