Some checks failed
Test Custom Executables / test-custom-executables (push) Has been cancelled
CI / test (push) Has been cancelled
CI / prettier (push) Has been cancelled
CI / typecheck (push) Has been cancelled
Sync Base Action to claude-code-base-action / Sync base-action to claude-code-base-action repository (push) Has been cancelled
Test Claude Code Action / test-inline-prompt (push) Has been cancelled
Test Claude Code Action / test-prompt-file (push) Has been cancelled
Test Claude Env Feature / test-claude-env-with-comments (push) Has been cancelled
Test MCP Servers / test-mcp-integration (push) Has been cancelled
Test MCP Servers / test-mcp-config-flag (push) Has been cancelled
Test Settings Feature / test-settings-inline-allow (push) Has been cancelled
Test Settings Feature / test-settings-inline-deny (push) Has been cancelled
Test Settings Feature / test-settings-file-allow (push) Has been cancelled
Test Settings Feature / test-settings-file-deny (push) Has been cancelled
Fork of markwylde/claude-code-gitea-action@b744372 (v1.0.21) with the 'View job' link fixed to use GITHUB_RUN_NUMBER (per-repo index) instead of GITHUB_RUN_ID (global id), because Forgejo routes run pages by per-repo index. See VENDOR.txt.
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
|
|
import { prepareMcpConfig } from "../src/mcp/install-mcp-server";
|
|
|
|
const originalEnv = { ...process.env };
|
|
|
|
describe("prepareMcpConfig", () => {
|
|
beforeEach(() => {
|
|
process.env.GITHUB_ACTION_PATH = "/action/path";
|
|
process.env.GITHUB_WORKSPACE = "/workspace";
|
|
process.env.GITEA_API_URL = "https://gitea.example.com/api/v1";
|
|
});
|
|
|
|
afterEach(() => {
|
|
process.env = { ...originalEnv };
|
|
});
|
|
|
|
test("returns base gitea and local git MCP servers", async () => {
|
|
const result = await prepareMcpConfig({
|
|
githubToken: "token",
|
|
owner: "owner",
|
|
repo: "repo",
|
|
branch: "branch",
|
|
});
|
|
|
|
const parsed = JSON.parse(result);
|
|
expect(Object.keys(parsed.mcpServers)).toEqual(["gitea", "local_git_ops"]);
|
|
|
|
expect(parsed.mcpServers.gitea).toEqual({
|
|
command: "bun",
|
|
args: ["run", "/action/path/src/mcp/gitea-mcp-server.ts"],
|
|
env: {
|
|
GITHUB_TOKEN: "token",
|
|
REPO_OWNER: "owner",
|
|
REPO_NAME: "repo",
|
|
BRANCH_NAME: "branch",
|
|
REPO_DIR: "/workspace",
|
|
GITEA_API_URL: "https://gitea.example.com/api/v1",
|
|
},
|
|
});
|
|
|
|
expect(parsed.mcpServers.local_git_ops.args[1]).toBe(
|
|
"/action/path/src/mcp/local-git-ops-server.ts",
|
|
);
|
|
});
|
|
|
|
test("falls back to process.cwd when workspace not provided", async () => {
|
|
delete process.env.GITHUB_WORKSPACE;
|
|
|
|
const result = await prepareMcpConfig({
|
|
githubToken: "token",
|
|
owner: "owner",
|
|
repo: "repo",
|
|
branch: "branch",
|
|
});
|
|
|
|
const parsed = JSON.parse(result);
|
|
expect(parsed.mcpServers.gitea.env.REPO_DIR).toBe(process.cwd());
|
|
});
|
|
});
|