1
0

Fix tests

This commit is contained in:
Zef Hemel 2022-10-11 11:43:28 +02:00
parent 09ac3ea36a
commit 9dd94c5397
5 changed files with 20 additions and 6 deletions

View File

@ -30,7 +30,7 @@ class DenoWorkerWrapper implements WorkerLike {
}
}
export function sanboxFactory(
export function sandboxFactory(
assetBundle: AssetBundle,
): (plug: Plug<any>) => Sandbox {
return (plug: Plug<any>) => {

View File

@ -1,4 +1,4 @@
import { createSandbox } from "../environments/deno_sandbox.ts";
import { sandboxFactory } from "../environments/deno_sandbox.ts";
import { Manifest } from "../types.ts";
import { EndpointHook, EndpointHookT } from "./endpoint.ts";
import { System } from "../system.ts";
@ -6,7 +6,11 @@ import { System } from "../system.ts";
import { Application } from "../../server/deps.ts";
import { assertEquals } from "../../test_deps.ts";
import assetBundle from "../../dist/asset_bundle.json" assert { type: "json" };
import { AssetBundle } from "../asset_bundle_reader.ts";
Deno.test("Run a plugos endpoint server", async () => {
const createSandbox = sandboxFactory(assetBundle as AssetBundle);
let system = new System<EndpointHookT>("server");
let plug = await system.load(
{

View File

@ -1,4 +1,4 @@
import { createSandbox } from "./environments/deno_sandbox.ts";
import { sandboxFactory } from "./environments/deno_sandbox.ts";
import { System } from "./system.ts";
import {
@ -6,7 +6,10 @@ import {
assertEquals,
} from "https://deno.land/std@0.158.0/testing/asserts.ts";
import assetBundle from "../dist/asset_bundle.json" assert { type: "json" };
Deno.test("Run a deno sandbox", async () => {
const createSandbox = sandboxFactory(assetBundle as AssetBundle);
const system = new System("server");
system.registerSyscalls([], {
addNumbers: (_ctx, a, b) => {
@ -122,9 +125,12 @@ Deno.test("Run a deno sandbox", async () => {
import { bundle as plugOsBundle } from "./bin/plugos-bundle.ts";
import { esbuild } from "./compile.ts";
import { AssetBundle } from "./asset_bundle_reader.ts";
const __dirname = new URL(".", import.meta.url).pathname;
Deno.test("Preload dependencies", async () => {
const createSandbox = sandboxFactory(assetBundle as AssetBundle);
const globalModules = await plugOsBundle(
`${__dirname}../plugs/global.plug.yaml`,
);

View File

@ -1,10 +1,14 @@
import { assertEquals } from "../../test_deps.ts";
import { SQLite } from "../../server/deps.ts";
import { createSandbox } from "../environments/deno_sandbox.ts";
import { sandboxFactory } from "../environments/deno_sandbox.ts";
import { System } from "../system.ts";
import { ensureTable, storeSyscalls } from "./store.deno.ts";
import assetBundle from "../../dist/asset_bundle.json" assert { type: "json" };
import { AssetBundle } from "../asset_bundle_reader.ts";
Deno.test("Test store", async () => {
const createSandbox = sandboxFactory(assetBundle as AssetBundle);
const db = new SQLite(":memory:");
await ensureTable(db, "test_table");
const system = new System("server");

View File

@ -14,7 +14,7 @@ import { Space } from "../common/spaces/space.ts";
import { SpacePrimitives } from "../common/spaces/space_primitives.ts";
import { markdownSyscalls } from "../common/syscalls/markdown.ts";
import { parseYamlSettings } from "../common/util.ts";
import { sanboxFactory } from "../plugos/environments/deno_sandbox.ts";
import { sandboxFactory } from "../plugos/environments/deno_sandbox.ts";
import { EndpointHook } from "../plugos/hooks/endpoint.ts";
import { EventHook } from "../plugos/hooks/event.ts";
import { DenoCronHook } from "../plugos/hooks/cron.deno.ts";
@ -177,7 +177,7 @@ export class HttpServer {
const { data } = await this.space.readAttachment(plugName, "string");
await this.system.load(
JSON.parse(data as string),
sanboxFactory(this.assetBundle),
sandboxFactory(this.assetBundle),
);
}
this.rebuildMdExtensions();