1
0
silverbullet/cli/plug_run.test.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-08-04 16:56:55 +00:00
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
import { compileManifest } from "../plugos/compile.ts";
import { esbuild } from "../plugos/deps.ts";
import { runPlug } from "./plug_run.ts";
import assets from "../dist/plug_asset_bundle.json" assert {
type: "json",
};
import { assertEquals } from "../test_deps.ts";
import { path } from "../common/deps.ts";
Deno.test("Test plug run", {
sanitizeResources: false,
sanitizeOps: false,
}, async () => {
2023-08-04 16:56:55 +00:00
// const tempDir = await Deno.makeTempDir();
2023-08-30 15:25:54 +00:00
const tempDbFile = await Deno.makeTempFile({ suffix: ".db" });
2023-08-04 16:56:55 +00:00
const assetBundle = new AssetBundle(assets);
const testFolder = path.dirname(new URL(import.meta.url).pathname);
const testSpaceFolder = path.join(testFolder, "test_space");
const plugFolder = path.join(testSpaceFolder, "_plug");
await Deno.mkdir(plugFolder, { recursive: true });
await compileManifest(
path.join(testFolder, "test.plug.yaml"),
plugFolder,
);
assertEquals(
await runPlug(
testSpaceFolder,
2023-08-30 15:25:54 +00:00
tempDbFile,
2023-08-04 16:56:55 +00:00
"test.run",
[],
assetBundle,
),
"Hello",
);
// await Deno.remove(tempDir, { recursive: true });
esbuild.stop();
2023-08-30 15:25:54 +00:00
await Deno.remove(tempDbFile);
2023-08-04 16:56:55 +00:00
});