mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:28:38 +00:00
test: share plugin install path fixtures
This commit is contained in:
@@ -7,6 +7,25 @@ import {
|
|||||||
formatPluginInstallPathIssue,
|
formatPluginInstallPathIssue,
|
||||||
} from "./plugin-install-path-warnings.js";
|
} from "./plugin-install-path-warnings.js";
|
||||||
|
|
||||||
|
async function detectMatrixCustomPathIssue(sourcePath: string | ((pluginPath: string) => string)) {
|
||||||
|
return withTempHome(async (home) => {
|
||||||
|
const pluginPath = path.join(home, "matrix-plugin");
|
||||||
|
await fs.mkdir(pluginPath, { recursive: true });
|
||||||
|
const resolvedSourcePath =
|
||||||
|
typeof sourcePath === "function" ? sourcePath(pluginPath) : sourcePath;
|
||||||
|
const issue = await detectPluginInstallPathIssue({
|
||||||
|
pluginId: "matrix",
|
||||||
|
install: {
|
||||||
|
source: "path",
|
||||||
|
sourcePath: resolvedSourcePath,
|
||||||
|
installPath: pluginPath,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return { issue, pluginPath };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe("plugin install path warnings", () => {
|
describe("plugin install path warnings", () => {
|
||||||
it("ignores non-path installs and blank path candidates", async () => {
|
it("ignores non-path installs and blank path candidates", async () => {
|
||||||
expect(
|
expect(
|
||||||
@@ -57,46 +76,22 @@ describe("plugin install path warnings", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses the second candidate path when the first one is stale", async () => {
|
it("uses the second candidate path when the first one is stale", async () => {
|
||||||
await withTempHome(async (home) => {
|
const { issue, pluginPath } = await detectMatrixCustomPathIssue("/tmp/openclaw-matrix-missing");
|
||||||
const pluginPath = path.join(home, "matrix-plugin");
|
expect(issue).toEqual({
|
||||||
await fs.mkdir(pluginPath, { recursive: true });
|
kind: "custom-path",
|
||||||
|
pluginId: "matrix",
|
||||||
const issue = await detectPluginInstallPathIssue({
|
path: pluginPath,
|
||||||
pluginId: "matrix",
|
|
||||||
install: {
|
|
||||||
source: "path",
|
|
||||||
sourcePath: "/tmp/openclaw-matrix-missing",
|
|
||||||
installPath: pluginPath,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(issue).toEqual({
|
|
||||||
kind: "custom-path",
|
|
||||||
pluginId: "matrix",
|
|
||||||
path: pluginPath,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("detects active custom plugin install paths", async () => {
|
it("detects active custom plugin install paths", async () => {
|
||||||
await withTempHome(async (home) => {
|
const { issue, pluginPath } = await detectMatrixCustomPathIssue(
|
||||||
const pluginPath = path.join(home, "matrix-plugin");
|
(resolvedPluginPath) => resolvedPluginPath,
|
||||||
await fs.mkdir(pluginPath, { recursive: true });
|
);
|
||||||
|
expect(issue).toEqual({
|
||||||
const issue = await detectPluginInstallPathIssue({
|
kind: "custom-path",
|
||||||
pluginId: "matrix",
|
pluginId: "matrix",
|
||||||
install: {
|
path: pluginPath,
|
||||||
source: "path",
|
|
||||||
sourcePath: pluginPath,
|
|
||||||
installPath: pluginPath,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(issue).toEqual({
|
|
||||||
kind: "custom-path",
|
|
||||||
pluginId: "matrix",
|
|
||||||
path: pluginPath,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user