mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 11:02:26 +00:00
fix(test): require lifecycle uninstall config proof
This commit is contained in:
@@ -39,6 +39,10 @@ function config() {
|
||||
return readJson(process.env.OPENCLAW_CONFIG_PATH ?? openclawPath("openclaw.json"));
|
||||
}
|
||||
|
||||
function requiredConfig() {
|
||||
return readRequiredJson(process.env.OPENCLAW_CONFIG_PATH ?? openclawPath("openclaw.json"));
|
||||
}
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
@@ -117,7 +121,7 @@ function printInstallPath(pluginId) {
|
||||
}
|
||||
|
||||
function assertUninstalled(pluginId) {
|
||||
const cfg = config();
|
||||
const cfg = requiredConfig();
|
||||
const record = recordFor(pluginId);
|
||||
assert(!record, `install record still present for ${pluginId}`);
|
||||
assert(!cfg.plugins?.entries?.[pluginId], `plugin config entry still present for ${pluginId}`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Plugin Lifecycle Probe tests cover plugin lifecycle probe script behavior.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
@@ -72,4 +72,16 @@ describe("plugin lifecycle matrix probe", () => {
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain(`failed to read JSON from ${inspectPath}`);
|
||||
});
|
||||
|
||||
it("rejects unreadable config during uninstall proof", () => {
|
||||
const dir = makeTempDir();
|
||||
const configPath = path.join(dir, ".openclaw", "openclaw.json");
|
||||
mkdirSync(path.dirname(configPath), { recursive: true });
|
||||
writeFileSync(configPath, "{ malformed\n", "utf8");
|
||||
|
||||
const result = runProbe(["assert-uninstalled", "lifecycle-claw"], dir);
|
||||
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain(`failed to read JSON from ${configPath}`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user