summaryrefslogtreecommitdiff
path: root/std/http/server_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-24 17:24:58 +0100
committerGitHub <noreply@github.com>2020-03-24 12:24:58 -0400
commit30bcf6a2ea620aa989a7362e7f4a62fc11743bb4 (patch)
treea1e0721425a34c40142230fe392cac15170a6791 /std/http/server_test.ts
parentb2478f3a217d5decbb638bf46e169ee58f17adad (diff)
Revert "avoid using same port number for test (#4147)"
Ref #4467 This reverts commit 60cee4f045778777a16b6fffd6d5b9a1400d7246.
Diffstat (limited to 'std/http/server_test.ts')
-rw-r--r--std/http/server_test.ts23
1 files changed, 7 insertions, 16 deletions
diff --git a/std/http/server_test.ts b/std/http/server_test.ts
index d9ce3ba97..f66b190b2 100644
--- a/std/http/server_test.ts
+++ b/std/http/server_test.ts
@@ -18,7 +18,6 @@ import { BufReader, BufWriter } from "../io/bufio.ts";
import { delay } from "../util/async.ts";
import { encode, decode } from "../strings/mod.ts";
import { mockConn } from "./mock.ts";
-import { randomPort } from "./test_util.ts";
const { Buffer, test } = Deno;
@@ -356,14 +355,8 @@ test({
ignore: true,
fn: async (): Promise<void> => {
// Runs a simple server as another process
- const port = randomPort();
const p = Deno.run({
- cmd: [
- Deno.execPath(),
- "--allow-net",
- "http/testdata/simple_server.ts",
- `${port}`
- ],
+ cmd: [Deno.execPath(), "--allow-net", "http/testdata/simple_server.ts"],
stdout: "piped"
});
@@ -402,15 +395,13 @@ test({
// FIXME(bartlomieju): hangs on windows, cause can't do `Deno.kill`
ignore: true,
fn: async (): Promise<void> => {
- const port = randomPort();
// Runs a simple server as another process
const p = Deno.run({
cmd: [
Deno.execPath(),
"--allow-net",
"--allow-read",
- "http/testdata/simple_https_server.ts",
- `${port}`
+ "http/testdata/simple_https_server.ts"
],
stdout: "piped"
});
@@ -422,6 +413,7 @@ test({
serverIsRunning = false;
})
.catch((_): void => {}); // Ignores the error when closing the process.
+
try {
const r = new TextProtoReader(new BufReader(p.stdout!));
const s = await r.readLine();
@@ -432,7 +424,7 @@ test({
// Requests to the server and immediately closes the connection
const conn = await Deno.connectTLS({
hostname: "localhost",
- port,
+ port: 4503,
certFile: "http/testdata/tls/RootCA.pem"
});
await Deno.writeAll(
@@ -456,7 +448,7 @@ test({
});
test("close server while iterating", async (): Promise<void> => {
- const server = serve({ port: randomPort() });
+ const server = serve(":8123");
const nextWhileClosing = server[Symbol.asyncIterator]().next();
server.close();
assertEquals(await nextWhileClosing, { value: undefined, done: true });
@@ -499,9 +491,8 @@ test({
test({
name: "respond error closes connection",
async fn(): Promise<void> {
- const port = randomPort();
const serverRoutine = async (): Promise<void> => {
- const server = serve(":" + port);
+ const server = serve(":8124");
// @ts-ignore
for await (const req of server) {
await assertThrowsAsync(async () => {
@@ -518,7 +509,7 @@ test({
const p = serverRoutine();
const conn = await Deno.connect({
hostname: "127.0.0.1",
- port
+ port: 8124
});
await Deno.writeAll(
conn,