mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 03:31:35 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -4,12 +4,12 @@ import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { MoltbotConfig } from "../config/config.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { loadCostUsageSummary, loadSessionCostSummary } from "./session-cost-usage.js";
|
||||
|
||||
describe("session cost usage", () => {
|
||||
it("aggregates daily totals with log cost and pricing fallback", async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-cost-"));
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-cost-"));
|
||||
const sessionsDir = path.join(root, "agents", "main", "sessions");
|
||||
await fs.mkdir(sessionsDir, { recursive: true });
|
||||
const sessionFile = path.join(sessionsDir, "sess-1.jsonl");
|
||||
@@ -92,23 +92,23 @@ describe("session cost usage", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
} as MoltbotConfig;
|
||||
} as OpenClawConfig;
|
||||
|
||||
const originalState = process.env.CLAWDBOT_STATE_DIR;
|
||||
process.env.CLAWDBOT_STATE_DIR = root;
|
||||
const originalState = process.env.OPENCLAW_STATE_DIR;
|
||||
process.env.OPENCLAW_STATE_DIR = root;
|
||||
try {
|
||||
const summary = await loadCostUsageSummary({ days: 30, config });
|
||||
expect(summary.daily.length).toBe(1);
|
||||
expect(summary.totals.totalTokens).toBe(50);
|
||||
expect(summary.totals.totalCost).toBeCloseTo(0.03003, 5);
|
||||
} finally {
|
||||
if (originalState === undefined) delete process.env.CLAWDBOT_STATE_DIR;
|
||||
else process.env.CLAWDBOT_STATE_DIR = originalState;
|
||||
if (originalState === undefined) delete process.env.OPENCLAW_STATE_DIR;
|
||||
else process.env.OPENCLAW_STATE_DIR = originalState;
|
||||
}
|
||||
});
|
||||
|
||||
it("summarizes a single session file", async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-cost-session-"));
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-cost-session-"));
|
||||
const sessionFile = path.join(root, "session.jsonl");
|
||||
const now = new Date();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user