Skip to content

Commit

Permalink
Add runFlags test and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmcd committed May 1, 2024
1 parent b930937 commit d8d2aa5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/DenoHTTPWorker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
worker.terminate();
});

describe("runFlags editing", () => {
it.each([
"--allow-read",
"--allow-write",
"--allow-read=/dev/null",
"--allow-write=/dev/null",
])("should handle %s", async (flag) => {
let worker = await newDenoHTTPWorker(echoScript, {
printOutput: true,
runFlags: [flag],
});
await worker.client.get("https://localhost/").json();
await worker.terminate();
});
});

it("should be able to import script", async () => {
const file = path.resolve(__dirname, "./test/echo-request.ts");
const url = new URL(`file://${file}`);
Expand All @@ -60,7 +76,6 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
it("user agent is not overwritten", async () => {
let worker = await newDenoHTTPWorker(echoScript, {
printOutput: true,
runFlags: [`--unstable-http`],
});
let resp: any = await worker.client
.get("https://localhost/", {
Expand Down
2 changes: 1 addition & 1 deletion src/DenoHTTPWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const newDenoHTTPWorker = async (
return (flag += "," + allowReadFlagValue);
}
if (flag.startsWith("--allow-write=")) {
allowReadFound = true;
allowWriteFound = true;
return (flag += "," + socketFile);
}
return flag;
Expand Down

0 comments on commit d8d2aa5

Please sign in to comment.