Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-enable chast server example tests #4457

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion std/examples/chat/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { listenAndServe } from "../../http/server.ts";
import * as path from "../../path/mod.ts";
import {
acceptWebSocket,
acceptable,
Expand Down Expand Up @@ -48,7 +49,7 @@ listenAndServe(addr, async req => {
});
} else {
// server launched by deno run ./server.ts
const file = await Deno.open(u.pathname);
const file = await Deno.open(path.resolve(u.href));
req.respond({
status: 200,
headers: new Headers({
Expand Down
9 changes: 2 additions & 7 deletions std/examples/chat/server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { delay } from "../../util/async.ts";

const port = randomPort();

const { test, build } = Deno;
const { test } = Deno;

async function startServer(): Promise<Deno.Process> {
const server = Deno.run({
cmd: [
Deno.execPath(),
"--allow-net",
"--allow-read",
"server.ts",
"./server.ts",
`127.0.0.1:${port}`
],
cwd: "examples/chat",
Expand All @@ -35,11 +35,7 @@ async function startServer(): Promise<Deno.Process> {
return server;
}

// TODO: https://github.com/denoland/deno/issues/4108
const ignore = build.os == "win";

test({
ignore,
name: "GET / should serve html",
async fn() {
const server = await startServer();
Expand All @@ -58,7 +54,6 @@ test({
});

test({
ignore,
name: "GET /ws should upgrade conn to ws",
async fn() {
const server = await startServer();
Expand Down
6 changes: 3 additions & 3 deletions std/http/server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ test({
await req.respond({ body: new TextEncoder().encode(req.url) });
}
}

const server = serve(":8123");
const port = randomPort();
const server = serve({ port });
const p = iteratorReq(server);
const conn = await Deno.connect({ hostname: "127.0.0.1", port: 8123 });
const conn = await Deno.connect({ hostname: "127.0.0.1", port });
await Deno.writeAll(
conn,
new TextEncoder().encode("GET /hello HTTP/1.1\r\n\r\n")
Expand Down