mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Add tests for monorepo plugins and non-plugin packages
This commit is contained in:
1 parent
427acfe82e
commit
2e729b9e47
1 file changed
+17
@@ -119,6 +119,8 @@ describe("lib/plugin_loader", function() {
|
|||||||
const externalPluginPath = path.join(baseDir, "external_plugins", "external_plugin");
|
const externalPluginPath = path.join(baseDir, "external_plugins", "external_plugin");
|
||||||
const externalPluginPathAbs = path.resolve(externalPluginPath);
|
const externalPluginPathAbs = path.resolve(externalPluginPath);
|
||||||
const npmPluginPath = path.join(baseDir, "node_modules", "npm-plugin");
|
const npmPluginPath = path.join(baseDir, "node_modules", "npm-plugin");
|
||||||
|
const monorepoPluginPath = path.join(baseDir, "external_plugins", "monorepo", "monorepo-plugin");
|
||||||
|
const monorepoPluginPathAbs = path.resolve(monorepoPluginPath);
|
||||||
let pluginList;
|
let pluginList;
|
||||||
|
|
||||||
before(async function() {
|
before(async function() {
|
||||||
@@ -144,15 +146,23 @@ describe("lib/plugin_loader", function() {
|
|||||||
await writePlugin(externalPluginPath, "external_plugin");
|
await writePlugin(externalPluginPath, "external_plugin");
|
||||||
// Create npm plugin
|
// Create npm plugin
|
||||||
await writePlugin(npmPluginPath, "npm");
|
await writePlugin(npmPluginPath, "npm");
|
||||||
|
// Write a monorepo plugin
|
||||||
|
await writePlugin(monorepoPluginPath, "monorepo-plugin");
|
||||||
// Create root package.json
|
// Create root package.json
|
||||||
await fs.outputFile(
|
await fs.outputFile(
|
||||||
path.join(baseDir, "package.json"),
|
path.join(baseDir, "package.json"),
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
dependencies: {
|
dependencies: {
|
||||||
"npm-plugin": "^1.0.0",
|
"npm-plugin": "^1.0.0",
|
||||||
|
"not-a-plugin": "^1.0.0",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
// Create an npm module that is not a plugin
|
||||||
|
await fs.outputFile(
|
||||||
|
path.join(baseDir, "node_modules", "not-a-plugin", "package.json"),
|
||||||
|
JSON.stringify({ name: "not-a-plugin", version: "1.0.0" })
|
||||||
|
);
|
||||||
|
|
||||||
process.chdir(baseDir);
|
process.chdir(baseDir);
|
||||||
pluginList = await lib.loadPluginList(pluginListPath, true);
|
pluginList = await lib.loadPluginList(pluginListPath, true);
|
||||||
@@ -171,6 +181,8 @@ describe("lib/plugin_loader", function() {
|
|||||||
it("should discover npm plugins", async function() {
|
it("should discover npm plugins", async function() {
|
||||||
assert.ok(pluginList.has("npm"));
|
assert.ok(pluginList.has("npm"));
|
||||||
assert.strictEqual(pluginList.get("npm"), "npm-plugin");
|
assert.strictEqual(pluginList.get("npm"), "npm-plugin");
|
||||||
|
// Check that it does not contain not-a-plugin
|
||||||
|
assert.strictEqual(pluginList.get("not-a-plugin"), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load existing plugin list", async function() {
|
it("should load existing plugin list", async function() {
|
||||||
@@ -181,6 +193,11 @@ describe("lib/plugin_loader", function() {
|
|||||||
assert.strictEqual(loadedPlugins.get("test"), "/test/path");
|
assert.strictEqual(loadedPlugins.get("test"), "/test/path");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should support monorepo plugins", async function() {
|
||||||
|
assert.ok(pluginList.has("monorepo-plugin"));
|
||||||
|
assert.strictEqual(pluginList.get("monorepo-plugin"), monorepoPluginPathAbs);
|
||||||
|
});
|
||||||
|
|
||||||
after(async function() {
|
after(async function() {
|
||||||
process.chdir(old_cwd);
|
process.chdir(old_cwd);
|
||||||
await fs.remove(baseDir);
|
await fs.remove(baseDir);
|
||||||
|
|||||||
Reference in new issue
Block a user