summaryrefslogtreecommitdiff
path: root/std/examples/tests/echo_server_test.ts
diff options
context:
space:
mode:
authorYusuke Sakurai <kerokerokerop@gmail.com>2020-03-21 22:53:47 +0900
committerGitHub <noreply@github.com>2020-03-21 09:53:47 -0400
commit60cee4f045778777a16b6fffd6d5b9a1400d7246 (patch)
treea477bd147fbd548d478a289af5bd0681b1a34c4e /std/examples/tests/echo_server_test.ts
parent0adc86f105204b2475126c36dfc10e678f67df56 (diff)
avoid using same port number for test (#4147)
Diffstat (limited to 'std/examples/tests/echo_server_test.ts')
-rw-r--r--std/examples/tests/echo_server_test.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/std/examples/tests/echo_server_test.ts b/std/examples/tests/echo_server_test.ts
index 20fd7479c..3c1893342 100644
--- a/std/examples/tests/echo_server_test.ts
+++ b/std/examples/tests/echo_server_test.ts
@@ -1,12 +1,14 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assertStrictEq, assertNotEquals } from "../../testing/asserts.ts";
import { BufReader, ReadLineResult } from "../../io/bufio.ts";
+import { randomPort } from "../../http/test_util.ts";
+const port = randomPort();
Deno.test("[examples/echo_server]", async () => {
const encoder = new TextEncoder();
const decoder = new TextDecoder();
const process = Deno.run({
- args: [Deno.execPath(), "--allow-net", "echo_server.ts"],
+ args: [Deno.execPath(), "--allow-net", "echo_server.ts", `${port}`],
cwd: "examples",
stdout: "piped"
});
@@ -19,10 +21,10 @@ Deno.test("[examples/echo_server]", async () => {
assertNotEquals(message, Deno.EOF);
assertStrictEq(
decoder.decode((message as ReadLineResult).line).trim(),
- "Listening on 0.0.0.0:8080"
+ "Listening on 0.0.0.0:" + port
);
- conn = await Deno.connect({ hostname: "127.0.0.1", port: 8080 });
+ conn = await Deno.connect({ hostname: "127.0.0.1", port });
const connReader = new BufReader(conn);
await conn.write(encoder.encode("Hello echo_server\n"));