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
+1 -1
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>) => {
+5 -1
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(
{
+7 -1
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`,
);
+5 -1
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");