Files
llmwiki-cli/test/git-credentials.test.ts
doum1004 51b4ce6ca7 feat: enhance git integration and improve wiki initialization
- Updated wiki initialization command to use `wiki init` with backend options.
- Introduced `resolvedGitToken` function to prioritize environment variables for GitHub PAT.
- Added `renameCurrentBranchToMain` function to standardize branch naming for GitHub Pages.
- Changed default repository visibility to public for easier GitHub Pages usage.
- Refactored Git provider creation to utilize resolved Git token.
- Modified template generation to include new environment variables and improved styling.
- Added tests for new functionalities including token resolution and branch renaming.
2026-04-12 23:25:25 -04:00

37 lines
1.0 KiB
TypeScript

import { describe, it, expect, afterEach } from "bun:test";
import { resolvedGitToken } from "../src/lib/git-credentials.ts";
import type { WikiConfig } from "../src/types.ts";
describe("resolvedGitToken", () => {
afterEach(() => {
delete process.env.LLMWIKI_GIT_TOKEN;
delete process.env.GITHUB_TOKEN;
delete process.env.GIT_TOKEN;
});
it("prefers LLMWIKI_GIT_TOKEN over YAML", () => {
process.env.LLMWIKI_GIT_TOKEN = "env-pat";
const config: WikiConfig = {
name: "w",
domain: "g",
created: "x",
backend: "git",
git: { repo: "o/r", token: "yaml-pat" },
paths: { raw: "r", wiki: "w", schema: "S" },
};
expect(resolvedGitToken(config)).toBe("env-pat");
});
it("falls back to git.token in config", () => {
const config: WikiConfig = {
name: "w",
domain: "g",
created: "x",
backend: "git",
git: { repo: "o/r", token: "yaml-only" },
paths: { raw: "r", wiki: "w", schema: "S" },
};
expect(resolvedGitToken(config)).toBe("yaml-only");
});
});