test(gateway): fix config.patch baseHash fixtures
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { connectOk, onceMessage, startServerWithClient } from "./test-helpers.js";
|
import { connectOk, installGatewayTestHooks, onceMessage, startServerWithClient } from "./test-helpers.js";
|
||||||
|
|
||||||
|
installGatewayTestHooks();
|
||||||
|
|
||||||
describe("gateway config.patch", () => {
|
describe("gateway config.patch", () => {
|
||||||
it("merges patches without clobbering unrelated config", async () => {
|
it("merges patches without clobbering unrelated config", async () => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import crypto from "node:crypto";
|
||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
@@ -157,16 +158,20 @@ vi.mock("../config/sessions.js", async () => {
|
|||||||
vi.mock("../config/config.js", async () => {
|
vi.mock("../config/config.js", async () => {
|
||||||
const actual = await vi.importActual<typeof import("../config/config.js")>("../config/config.js");
|
const actual = await vi.importActual<typeof import("../config/config.js")>("../config/config.js");
|
||||||
const resolveConfigPath = () => path.join(os.homedir(), ".clawdbot", "clawdbot.json");
|
const resolveConfigPath = () => path.join(os.homedir(), ".clawdbot", "clawdbot.json");
|
||||||
|
const hashConfigRaw = (raw: string | null) =>
|
||||||
|
crypto.createHash("sha256").update(raw ?? "").digest("hex");
|
||||||
|
|
||||||
const readConfigFileSnapshot = async () => {
|
const readConfigFileSnapshot = async () => {
|
||||||
if (testState.legacyIssues.length > 0) {
|
if (testState.legacyIssues.length > 0) {
|
||||||
|
const raw = JSON.stringify(testState.legacyParsed ?? {});
|
||||||
return {
|
return {
|
||||||
path: resolveConfigPath(),
|
path: resolveConfigPath(),
|
||||||
exists: true,
|
exists: true,
|
||||||
raw: JSON.stringify(testState.legacyParsed ?? {}),
|
raw,
|
||||||
parsed: testState.legacyParsed ?? {},
|
parsed: testState.legacyParsed ?? {},
|
||||||
valid: false,
|
valid: false,
|
||||||
config: {},
|
config: {},
|
||||||
|
hash: hashConfigRaw(raw),
|
||||||
issues: testState.legacyIssues.map((issue) => ({
|
issues: testState.legacyIssues.map((issue) => ({
|
||||||
path: issue.path,
|
path: issue.path,
|
||||||
message: issue.message,
|
message: issue.message,
|
||||||
@@ -185,6 +190,7 @@ vi.mock("../config/config.js", async () => {
|
|||||||
parsed: {},
|
parsed: {},
|
||||||
valid: true,
|
valid: true,
|
||||||
config: {},
|
config: {},
|
||||||
|
hash: hashConfigRaw(null),
|
||||||
issues: [],
|
issues: [],
|
||||||
legacyIssues: [],
|
legacyIssues: [],
|
||||||
};
|
};
|
||||||
@@ -199,6 +205,7 @@ vi.mock("../config/config.js", async () => {
|
|||||||
parsed,
|
parsed,
|
||||||
valid: true,
|
valid: true,
|
||||||
config: parsed,
|
config: parsed,
|
||||||
|
hash: hashConfigRaw(raw),
|
||||||
issues: [],
|
issues: [],
|
||||||
legacyIssues: [],
|
legacyIssues: [],
|
||||||
};
|
};
|
||||||
@@ -210,6 +217,7 @@ vi.mock("../config/config.js", async () => {
|
|||||||
parsed: {},
|
parsed: {},
|
||||||
valid: false,
|
valid: false,
|
||||||
config: {},
|
config: {},
|
||||||
|
hash: hashConfigRaw(null),
|
||||||
issues: [{ path: "", message: `read failed: ${String(err)}` }],
|
issues: [{ path: "", message: `read failed: ${String(err)}` }],
|
||||||
legacyIssues: [],
|
legacyIssues: [],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user