summaryrefslogtreecommitdiff
path: root/std/examples/tests
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/examples/tests
parentb2478f3a217d5decbb638bf46e169ee58f17adad (diff)
Revert "avoid using same port number for test (#4147)"
Ref #4467 This reverts commit 60cee4f045778777a16b6fffd6d5b9a1400d7246.
Diffstat (limited to 'std/examples/tests')
-rw-r--r--std/examples/tests/curl_test.ts11
-rw-r--r--std/examples/tests/echo_server_test.ts8
2 files changed, 5 insertions, 14 deletions
diff --git a/std/examples/tests/curl_test.ts b/std/examples/tests/curl_test.ts
index 3e3d4f78a..8d7634525 100644
--- a/std/examples/tests/curl_test.ts
+++ b/std/examples/tests/curl_test.ts
@@ -1,13 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { serve } from "../../http/server.ts";
import { assertStrictEq } from "../../testing/asserts.ts";
-import { randomPort } from "../../http/test_util.ts";
-const port = randomPort();
Deno.test({
name: "[examples/curl] send a request to a specified url",
fn: async () => {
- const server = serve({ port });
+ const server = serve({ port: 8081 });
const serverPromise = (async (): Promise<void> => {
for await (const req of server) {
req.respond({ body: "Hello world" });
@@ -16,12 +14,7 @@ Deno.test({
const decoder = new TextDecoder();
const process = Deno.run({
- cmd: [
- Deno.execPath(),
- "--allow-net",
- "curl.ts",
- "http://localhost:" + port
- ],
+ cmd: [Deno.execPath(), "--allow-net", "curl.ts", "http://localhost:8081"],
cwd: "examples",
stdout: "piped"
});
diff --git a/std/examples/tests/echo_server_test.ts b/std/examples/tests/echo_server_test.ts
index 164f65357..dd7336023 100644
--- a/std/examples/tests/echo_server_test.ts
+++ b/std/examples/tests/echo_server_test.ts
@@ -1,14 +1,12 @@
// 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({
- cmd: [Deno.execPath(), "--allow-net", "echo_server.ts", `${port}`],
+ cmd: [Deno.execPath(), "--allow-net", "echo_server.ts"],
cwd: "examples",
stdout: "piped"
});
@@ -21,10 +19,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:" + port
+ "Listening on 0.0.0.0:8080"
);
- conn = await Deno.connect({ hostname: "127.0.0.1", port });
+ conn = await Deno.connect({ hostname: "127.0.0.1", port: 8080 });
const connReader = new BufReader(conn);
await conn.write(encoder.encode("Hello echo_server\n"));