summaryrefslogtreecommitdiff
path: root/std/http/file_server_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/http/file_server_test.ts')
-rw-r--r--std/http/file_server_test.ts28
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();
+ }
+});