summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorVincent LE GOFF <g_n_s@hotmail.fr>2019-03-06 22:39:50 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-03-06 16:39:50 -0500
commite36edfdb3fd4709358a5f499f13cfe3d53c2b4f7 (patch)
tree1baef3f876a5e75288c3ec9056cdb93dd6b5787f /http
parentd29957ad17956016c35a04f5f1f98565e58e8a2e (diff)
Testing refactor (denoland/deno_std#240)
Original: https://github.com/denoland/deno_std/commit/e1d5c00279132aa639030c6c6d9b4e308bd4775e
Diffstat (limited to 'http')
-rw-r--r--http/file_server_test.ts9
-rw-r--r--http/server.ts2
-rw-r--r--http/server_test.ts21
3 files changed, 17 insertions, 15 deletions
diff --git a/http/file_server_test.ts b/http/file_server_test.ts
index cf4b8dcbd..7f2dfd278 100644
--- a/http/file_server_test.ts
+++ b/http/file_server_test.ts
@@ -1,7 +1,8 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { readFile, run } = Deno;
-import { test, assert, assertEqual } from "../testing/mod.ts";
+import { test } from "../testing/mod.ts";
+import { assert, assertEq } from "../testing/asserts.ts";
import { BufReader } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.ts";
@@ -35,12 +36,12 @@ test(async function serveFile() {
const res = await fetch("http://localhost:4500/azure-pipelines.yml");
assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers"));
- assertEqual(res.headers.get("content-type"), "text/yaml; charset=utf-8");
+ assertEq(res.headers.get("content-type"), "text/yaml; charset=utf-8");
const downloadedFile = await res.text();
const localFile = new TextDecoder().decode(
await readFile("./azure-pipelines.yml")
);
- assertEqual(downloadedFile, localFile);
+ assertEq(downloadedFile, localFile);
} finally {
killFileServer();
}
@@ -65,7 +66,7 @@ test(async function serveFallback() {
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"));
- assertEqual(res.status, 404);
+ assertEq(res.status, 404);
} finally {
killFileServer();
}
diff --git a/http/server.ts b/http/server.ts
index c6cd95f86..d39173045 100644
--- a/http/server.ts
+++ b/http/server.ts
@@ -4,7 +4,7 @@ import { Conn, Reader, Writer } from "deno";
import { BufReader, BufState, BufWriter } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.ts";
import { STATUS_TEXT } from "./http_status.ts";
-import { assert } from "../testing/mod.ts";
+import { assert } from "../testing/asserts.ts";
interface Deferred {
promise: Promise<{}>;
diff --git a/http/server_test.ts b/http/server_test.ts
index cc5863eb5..8bba36127 100644
--- a/http/server_test.ts
+++ b/http/server_test.ts
@@ -6,7 +6,8 @@
// https://github.com/golang/go/blob/master/src/net/http/responsewrite_test.go
const { Buffer } = Deno;
-import { assertEqual, test } from "../testing/mod.ts";
+import { test } from "../testing/mod.ts";
+import { assertEq } from "../testing/asserts.ts";
import { Response, ServerRequest } from "./server.ts";
import { BufReader, BufWriter } from "../io/bufio.ts";
@@ -46,7 +47,7 @@ test(async function responseWrite() {
request.w = bufw;
await request.respond(testCase.response);
- assertEqual(buf.toString(), testCase.raw);
+ assertEq(buf.toString(), testCase.raw);
}
});
@@ -58,7 +59,7 @@ test(async function requestBodyWithContentLength() {
const buf = new Buffer(enc.encode("Hello"));
req.r = new BufReader(buf);
const body = dec.decode(await req.body());
- assertEqual(body, "Hello");
+ assertEq(body, "Hello");
}
// Larger than internal buf
@@ -70,7 +71,7 @@ test(async function requestBodyWithContentLength() {
const buf = new Buffer(enc.encode(longText));
req.r = new BufReader(buf);
const body = dec.decode(await req.body());
- assertEqual(body, longText);
+ assertEq(body, longText);
}
});
@@ -95,7 +96,7 @@ test(async function requestBodyWithTransferEncoding() {
const buf = new Buffer(enc.encode(chunksData));
req.r = new BufReader(buf);
const body = dec.decode(await req.body());
- assertEqual(body, shortText);
+ assertEq(body, shortText);
}
// Larger than internal buf
@@ -119,7 +120,7 @@ test(async function requestBodyWithTransferEncoding() {
const buf = new Buffer(enc.encode(chunksData));
req.r = new BufReader(buf);
const body = dec.decode(await req.body());
- assertEqual(body, longText);
+ assertEq(body, longText);
}
});
@@ -135,7 +136,7 @@ test(async function requestBodyStreamWithContentLength() {
let offset = 0;
for await (const chunk of it) {
const s = dec.decode(chunk);
- assertEqual(shortText.substr(offset, s.length), s);
+ assertEq(shortText.substr(offset, s.length), s);
offset += s.length;
}
}
@@ -152,7 +153,7 @@ test(async function requestBodyStreamWithContentLength() {
let offset = 0;
for await (const chunk of it) {
const s = dec.decode(chunk);
- assertEqual(longText.substr(offset, s.length), s);
+ assertEq(longText.substr(offset, s.length), s);
offset += s.length;
}
}
@@ -182,7 +183,7 @@ test(async function requestBodyStreamWithTransferEncoding() {
let offset = 0;
for await (const chunk of it) {
const s = dec.decode(chunk);
- assertEqual(shortText.substr(offset, s.length), s);
+ assertEq(shortText.substr(offset, s.length), s);
offset += s.length;
}
}
@@ -211,7 +212,7 @@ test(async function requestBodyStreamWithTransferEncoding() {
let offset = 0;
for await (const chunk of it) {
const s = dec.decode(chunk);
- assertEqual(longText.substr(offset, s.length), s);
+ assertEq(longText.substr(offset, s.length), s);
offset += s.length;
}
}