perf(test): fold model-default assertions into command utils suite

This commit is contained in:
Peter Steinberger
2026-02-15 23:54:25 +00:00
parent 55fd88e967
commit 5baa08ed13
2 changed files with 22 additions and 24 deletions

View File

@@ -1,7 +1,8 @@
import path from "node:path";
import { describe, expect, test } from "vitest";
import { describe, expect, it, test } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { buildCleanupPlan } from "./cleanup-utils.js";
import { applyAgentDefaultPrimaryModel } from "./model-default.js";
describe("buildCleanupPlan", () => {
test("resolves inside-state flags and workspace dirs", () => {
@@ -29,3 +30,23 @@ describe("buildCleanupPlan", () => {
);
});
});
describe("applyAgentDefaultPrimaryModel", () => {
it("does not mutate when already set", () => {
const cfg = { agents: { defaults: { model: { primary: "a/b" } } } } as OpenClawConfig;
const result = applyAgentDefaultPrimaryModel({ cfg, model: "a/b" });
expect(result.changed).toBe(false);
expect(result.next).toBe(cfg);
});
it("normalizes legacy models", () => {
const cfg = { agents: { defaults: { model: { primary: "legacy" } } } } as OpenClawConfig;
const result = applyAgentDefaultPrimaryModel({
cfg,
model: "a/b",
legacyModels: new Set(["legacy"]),
});
expect(result.changed).toBe(false);
expect(result.next).toBe(cfg);
});
});

View File

@@ -1,23 +0,0 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { applyAgentDefaultPrimaryModel } from "./model-default.js";
describe("applyAgentDefaultPrimaryModel", () => {
it("does not mutate when already set", () => {
const cfg = { agents: { defaults: { model: { primary: "a/b" } } } } as OpenClawConfig;
const result = applyAgentDefaultPrimaryModel({ cfg, model: "a/b" });
expect(result.changed).toBe(false);
expect(result.next).toBe(cfg);
});
it("normalizes legacy models", () => {
const cfg = { agents: { defaults: { model: { primary: "legacy" } } } } as OpenClawConfig;
const result = applyAgentDefaultPrimaryModel({
cfg,
model: "a/b",
legacyModels: new Set(["legacy"]),
});
expect(result.changed).toBe(false);
expect(result.next).toBe(cfg);
});
});