diff options
author | matheus <marchiore.matheus@gmail.com> | 2020-06-03 14:48:03 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 13:48:03 -0400 |
commit | 94bf551ead0ab5dc922cb61d13b3141896d5a8ae (patch) | |
tree | d2e9dc2d2115d1b841f2cd83b59bdd02c245fba0 /std/http/file_server_test.ts | |
parent | 1ebd33092779edc630e8f809f72bcef2656b8185 (diff) |
fix(std/http/file_server): args handling only if invoked directly (#5989)
Diffstat (limited to 'std/http/file_server_test.ts')
-rw-r--r-- | std/http/file_server_test.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts index 97c07c250..dbbaf81ff 100644 --- a/std/http/file_server_test.ts +++ b/std/http/file_server_test.ts @@ -38,6 +38,24 @@ async function startFileServer({ assert(s !== null && s.includes("server listening")); } +async function startFileServerAsLibrary({}: FileServerCfg = {}): Promise<void> { + fileServer = await Deno.run({ + cmd: [ + Deno.execPath(), + "run", + "--allow-read", + "--allow-net", + "http/testdata/file_server_as_library.ts", + ], + stdout: "piped", + stderr: "null", + }); + assert(fileServer.stdout != null); + const r = new TextProtoReader(new BufReader(fileServer.stdout)); + const s = await r.readLine(); + assert(s !== null && s.includes("Server running...")); +} + async function killFileServer(): Promise<void> { fileServer.close(); // Process.close() kills the file server process. However this termination @@ -166,3 +184,13 @@ test("contentType", async () => { assertEquals(contentType, "text/html"); (response.body as Deno.File).close(); }); + +test("file_server running as library", async function (): Promise<void> { + await startFileServerAsLibrary(); + try { + const res = await fetch("http://localhost:8000"); + assertEquals(res.status, 200); + } finally { + await killFileServer(); + } +}); |