mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:21:23 +00:00
refactor(commands): share default model applier
This commit is contained in:
23
src/commands/model-default.test.ts
Normal file
23
src/commands/model-default.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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