Files
clawdbot/src/config/paths.test.ts
Peter Steinberger c379191f80 chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
2026-01-14 15:02:19 +00:00

30 lines
991 B
TypeScript

import path from "node:path";
import { describe, expect, it } from "vitest";
import { resolveOAuthDir, resolveOAuthPath } from "./paths.js";
describe("oauth paths", () => {
it("prefers CLAWDBOT_OAUTH_DIR over CLAWDBOT_STATE_DIR", () => {
const env = {
CLAWDBOT_OAUTH_DIR: "/custom/oauth",
CLAWDBOT_STATE_DIR: "/custom/state",
} as NodeJS.ProcessEnv;
expect(resolveOAuthDir(env, "/custom/state")).toBe(path.resolve("/custom/oauth"));
expect(resolveOAuthPath(env, "/custom/state")).toBe(
path.join(path.resolve("/custom/oauth"), "oauth.json"),
);
});
it("derives oauth path from CLAWDBOT_STATE_DIR when unset", () => {
const env = {
CLAWDBOT_STATE_DIR: "/custom/state",
} as NodeJS.ProcessEnv;
expect(resolveOAuthDir(env, "/custom/state")).toBe(path.join("/custom/state", "credentials"));
expect(resolveOAuthPath(env, "/custom/state")).toBe(
path.join("/custom/state", "credentials", "oauth.json"),
);
});
});