mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:11:24 +00:00
perf(test): fold model-default assertions into command utils suite
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import path from "node:path";
|
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 type { OpenClawConfig } from "../config/config.js";
|
||||||
import { buildCleanupPlan } from "./cleanup-utils.js";
|
import { buildCleanupPlan } from "./cleanup-utils.js";
|
||||||
|
import { applyAgentDefaultPrimaryModel } from "./model-default.js";
|
||||||
|
|
||||||
describe("buildCleanupPlan", () => {
|
describe("buildCleanupPlan", () => {
|
||||||
test("resolves inside-state flags and workspace dirs", () => {
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user