`pr create` takes --title (required), --body/--body-file, --base, --head,
--assignee, --reviewer, repeatable name-resolved --label, and --milestone.
An omitted --head defaults to the current local branch; an omitted --base to
the repository's default branch. Before creating, an existing open PR for the
same base/head pair short-circuits to `pull_request: { number, url, already:
true }` rather than opening a duplicate; only an open PR does, since a closed
one's branches are free to be proposed again.
`pr comment <n>` posts through the shared issue-comment endpoint and returns
the created comment as `comment: { number, author, created, body }` (ADR 0008),
reporting a 404 as PR_NOT_FOUND since the caller asked about a pull request.
That comment block is now built in one place (src/comment.ts) for both issue
and pr comment, as ADR 0008 requires them to stay identical.
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { runCliTest } from "./harness.js";
|
|
|
|
describe("--help", () => {
|
|
it("prints a top-level flag reference and exits 0", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["--help"]);
|
|
|
|
expect(exitCode).toBe(0);
|
|
expect(stdout).toContain("usage: gitea-axi");
|
|
expect(stdout).toContain("issue list");
|
|
expect(stdout).toContain("-R, --repo");
|
|
expect(stdout).toContain("--login");
|
|
});
|
|
|
|
it("prints the issue list flag reference and exits 0", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["issue", "list", "--help"]);
|
|
|
|
expect(exitCode).toBe(0);
|
|
expect(stdout).toContain("usage: gitea-axi issue list");
|
|
expect(stdout).toContain("--state");
|
|
expect(stdout).toContain("--limit");
|
|
});
|
|
|
|
it("prints the issue group help and exits 0", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["issue", "--help"]);
|
|
|
|
expect(exitCode).toBe(0);
|
|
expect(stdout).toContain("usage: gitea-axi issue");
|
|
expect(stdout).toContain("list");
|
|
});
|
|
|
|
it("prints the pr group help and exits 0", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["pr", "--help"]);
|
|
|
|
expect(exitCode).toBe(0);
|
|
expect(stdout).toContain("usage: gitea-axi pr");
|
|
expect(stdout).toContain("create");
|
|
expect(stdout).toContain("comment");
|
|
});
|
|
|
|
it("rejects an unknown pr subcommand with exit code 2", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["pr", "frobnicate"]);
|
|
|
|
expect(exitCode).toBe(2);
|
|
expect(stdout).toContain("code: VALIDATION_ERROR");
|
|
expect(stdout).toContain("frobnicate");
|
|
});
|
|
|
|
it("prints the version for --version", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["--version"]);
|
|
|
|
expect(exitCode).toBe(0);
|
|
expect(stdout.trim()).toMatch(/^\d+\.\d+\.\d+$/);
|
|
});
|
|
|
|
it("rejects unknown commands with exit code 2", async () => {
|
|
const { stdout, exitCode } = await runCliTest(["frobnicate"]);
|
|
|
|
expect(exitCode).toBe(2);
|
|
expect(stdout).toContain("code: VALIDATION_ERROR");
|
|
expect(stdout).toContain("frobnicate");
|
|
});
|
|
});
|