diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-03-24 17:24:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-24 12:24:58 -0400 |
commit | 30bcf6a2ea620aa989a7362e7f4a62fc11743bb4 (patch) | |
tree | a1e0721425a34c40142230fe392cac15170a6791 /std/http/file_server_test.ts | |
parent | b2478f3a217d5decbb638bf46e169ee58f17adad (diff) |
Revert "avoid using same port number for test (#4147)"
Ref #4467
This reverts commit 60cee4f045778777a16b6fffd6d5b9a1400d7246.
Diffstat (limited to 'std/http/file_server_test.ts')
-rw-r--r-- | std/http/file_server_test.ts | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts index d7f939dad..fcf776ea2 100644 --- a/std/http/file_server_test.ts +++ b/std/http/file_server_test.ts @@ -2,11 +2,9 @@ import { assert, assertEquals, assertStrContains } from "../testing/asserts.ts"; import { BufReader } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; -import { randomPort } from "./test_util.ts"; const { test } = Deno; let fileServer: Deno.Process; -const port = randomPort(); async function startFileServer(): Promise<void> { fileServer = Deno.run({ cmd: [ @@ -16,9 +14,7 @@ async function startFileServer(): Promise<void> { "--allow-net", "http/file_server.ts", ".", - "--cors", - "--port", - `${port}` + "--cors" ], stdout: "piped", stderr: "null" @@ -38,7 +34,7 @@ function killFileServer(): void { test(async function serveFile(): Promise<void> { await startFileServer(); try { - const res = await fetch(`http://localhost:${port}/README.md`); + const res = await fetch("http://localhost:4500/README.md"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assert(res.headers.has("content-type")); @@ -56,7 +52,7 @@ test(async function serveFile(): Promise<void> { test(async function serveDirectory(): Promise<void> { await startFileServer(); try { - const res = await fetch(`http://localhost:${port}/`); + const res = await fetch("http://localhost:4500/"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); const page = await res.text(); @@ -78,7 +74,7 @@ test(async function serveDirectory(): Promise<void> { test(async function serveFallback(): Promise<void> { await startFileServer(); try { - const res = await fetch(`http://localhost:${port}/badfile.txt`); + const res = await fetch("http://localhost:4500/badfile.txt"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assertEquals(res.status, 404); @@ -91,12 +87,12 @@ test(async function serveFallback(): Promise<void> { test(async function serveWithUnorthodoxFilename(): Promise<void> { await startFileServer(); try { - let res = await fetch(`http://localhost:${port}/http/testdata/%`); + let res = await fetch("http://localhost:4500/http/testdata/%"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assertEquals(res.status, 200); res.body.close(); - res = await fetch(`http://localhost:${port}/http/testdata/test%20file.txt`); + res = await fetch("http://localhost:4500/http/testdata/test%20file.txt"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assertEquals(res.status, 200); @@ -107,16 +103,8 @@ test(async function serveWithUnorthodoxFilename(): Promise<void> { }); test(async function servePermissionDenied(): Promise<void> { - const _port = randomPort(); const deniedServer = Deno.run({ - cmd: [ - Deno.execPath(), - "run", - "--allow-net", - "http/file_server.ts", - "-p", - `${_port}` - ], + cmd: [Deno.execPath(), "run", "--allow-net", "http/file_server.ts"], stdout: "piped", stderr: "piped" }); @@ -128,7 +116,7 @@ test(async function servePermissionDenied(): Promise<void> { assert(s !== Deno.EOF && s.includes("server listening")); try { - const res = await fetch(`http://localhost:${_port}/`); + const res = await fetch("http://localhost:4500/"); res.body.close(); assertStrContains( (await errReader.readLine()) as string, |