Browse Source

Choose test server port in a range

To fix random test failures
master
Michaël Lemaire 6 months ago
parent
commit
9c8aa11dea
  1. 1
      config/run.flags
  2. 1
      config/test.flags
  3. 19
      run
  4. 6
      server.ts
  5. 8
      testing.ts

1
config/run.flags

@ -0,0 +1 @@
--allow-read --allow-net --location https://rs.thunderk.net/

1
config/test.flags

@ -0,0 +1 @@
--allow-read --allow-net --location https://test.rs.thunderk.net/

19
run

@ -0,0 +1,19 @@
#!/bin/sh
# Simplified run tool for deno commands
if test $# -eq 0
then
echo "Usage: $0 [file or command]"
exit 1
elif echo $1 | grep -q '.*.ts'
then
denocmd=run
denoargs=$1
shift
else
denocmd=$1
shift
fi
denoargs="$(cat config/$denocmd.flags 2> /dev/null) $denoargs $@"
exec deno $denocmd $denoargs

6
server.ts

@ -1,8 +1,8 @@
#!/usr/bin/env -S deno run --allow-read --allow-net
import { getLocalStorage } from "./mod.ts";
#!./run
import { KeyValueStorage } from "./basic.ts";
import { HEADER_REPLYIER, HEADER_REQUESTER } from "./remote.ts";
import { json, opine, opineCors, readAll } from "./deps.ts";
import { getLocalStorage } from "./mod.ts";
import { HEADER_REPLYIER, HEADER_REQUESTER } from "./remote.ts";
const PORT = 5001;

8
testing.ts

@ -1,12 +1,12 @@
import { KeyValueStorage, MemoryStorage } from "./basic.ts";
import { expect } from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts";
import { getAvailablePort } from "https://deno.land/x/port@1.0.0/mod.ts";
import { KeyValueStorage, MemoryStorage } from "./basic.ts";
import { startRestServer } from "./server.ts";
export {
describe,
expect,
it,
} from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts";
import { getAvailablePort } from "https://deno.land/x/port@1.0.0/mod.ts";
import { startRestServer } from "./server.ts";
/**
* Basic high-level test suite for any kind storage
@ -43,7 +43,7 @@ export async function disableLocalStorage(
export async function runTestServer(
body: (url: string) => Promise<void>,
): Promise<void> {
const port = await getAvailablePort();
const port = await getAvailablePort({ port: { start: 3000, end: 30000 } });
if (!port) {
throw new Error("No port available for test server");
}

Loading…
Cancel
Save