silverbullet/cmd/test/plug_run.test.ts

40 lines
1.1 KiB
TypeScript
Raw Normal View History

import { AssetBundle } from "$lib/asset_bundle/bundle.ts";
import { compileManifest } from "../compile.ts";
import * as esbuild from "esbuild";
import assets from "../../dist/plug_asset_bundle.json" assert { type: "json" };
import { assertEquals } from "$std/testing/asserts.ts";
import { dirname, join } from "$std/path/mod.ts";
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
import { runPlug } from "../plug_run.ts";
2023-08-05 00:56:55 +08:00
Deno.test("Test plug run", {
sanitizeResources: false,
sanitizeOps: false,
}, async () => {
2023-08-05 00:56:55 +08:00
const assetBundle = new AssetBundle(assets);
const testFolder = dirname(new URL(import.meta.url).pathname);
const testSpaceFolder = join(testFolder, "test_space");
2023-08-05 00:56:55 +08:00
const plugFolder = join(testSpaceFolder, "_plug");
2023-08-05 00:56:55 +08:00
await Deno.mkdir(plugFolder, { recursive: true });
await compileManifest(
join(testFolder, "test_plug_run.plug.yaml"),
2023-08-05 00:56:55 +08:00
plugFolder,
);
assertEquals(
await runPlug(
testSpaceFolder,
"test.run",
[],
assetBundle,
new MemoryKvPrimitives(),
2023-08-05 00:56:55 +08:00
),
"Hello",
);
// await Deno.remove(tempDir, { recursive: true });
esbuild.stop();
});