diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2020-03-20 08:46:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 09:46:48 +0100 |
commit | 35f6e2e45ddb96524a6bdf54b0a6155caa88d5e0 (patch) | |
tree | 2bf6e2151ff488d3be141c56ed32b69aa867cab9 /std/http/server_test.ts | |
parent | b7e6a31a425901c089f4b524774b985906982fae (diff) |
fix(std/http): Properly await ops in a server test (#4436)
Diffstat (limited to 'std/http/server_test.ts')
-rw-r--r-- | std/http/server_test.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/std/http/server_test.ts b/std/http/server_test.ts index 2db44f260..0a4986dcf 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -462,12 +462,12 @@ test({ async fn(): Promise<void> { async function iteratorReq(server: Server): Promise<void> { for await (const req of server) { - req.respond({ body: new TextEncoder().encode(req.url) }); + await req.respond({ body: new TextEncoder().encode(req.url) }); } } const server = serve(":8123"); - iteratorReq(server); + const p = iteratorReq(server); const conn = await Deno.connect({ hostname: "127.0.0.1", port: 8123 }); await Deno.writeAll( conn, @@ -479,8 +479,7 @@ test({ const resStr = new TextDecoder().decode(res.subarray(0, nread)); assertStrContains(resStr, "/hello"); server.close(); - // Defer to allow async ops to resolve after server has been closed. - await delay(0); + await p; // Client connection should still be open, verify that // it's visible in resource table. const resources = Deno.resources(); |