mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
test: ignore fetchWithInvalidContentLength and fetchConnectionError on Windows (#18351)
https://github.com/denoland/deno/issues/18350
This commit is contained in:
parent
fd0658fb42
commit
2ac2906b2b
1 changed files with 33 additions and 50 deletions
|
@ -54,30 +54,11 @@ function findClosedPortInRange(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flakyTest(
|
|
||||||
fn: (t: Deno.TestContext) => Promise<void>,
|
|
||||||
) {
|
|
||||||
async function wrapperFn(t: Deno.TestContext) {
|
|
||||||
let lastError;
|
|
||||||
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
try {
|
|
||||||
await fn(t);
|
|
||||||
return;
|
|
||||||
} catch (e) {
|
|
||||||
lastError = e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw lastError;
|
|
||||||
}
|
|
||||||
Object.defineProperty(wrapperFn, "name", { value: fn.name });
|
|
||||||
return wrapperFn;
|
|
||||||
}
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { net: true } },
|
// TODO(bartlomieju): reenable this test
|
||||||
flakyTest(async function fetchConnectionError() {
|
// https://github.com/denoland/deno/issues/18350
|
||||||
|
{ ignore: Deno.build.os === "windows", permissions: { net: true } },
|
||||||
|
async function fetchConnectionError() {
|
||||||
const port = findClosedPortInRange(4000, 9999);
|
const port = findClosedPortInRange(4000, 9999);
|
||||||
await assertRejects(
|
await assertRejects(
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -86,7 +67,7 @@ Deno.test(
|
||||||
TypeError,
|
TypeError,
|
||||||
"error trying to connect",
|
"error trying to connect",
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
|
@ -1697,38 +1678,38 @@ function invalidServer(addr: string, body: Uint8Array): Deno.Listener {
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { net: true } },
|
{ permissions: { net: true } },
|
||||||
flakyTest(
|
async function fetchWithInvalidContentLengthAndTransferEncoding(): Promise<
|
||||||
async function fetchWithInvalidContentLengthAndTransferEncoding(): Promise<
|
void
|
||||||
void
|
> {
|
||||||
> {
|
const addr = "127.0.0.1:4516";
|
||||||
const addr = "127.0.0.1:4516";
|
const data = "a".repeat(10 << 10);
|
||||||
const data = "a".repeat(10 << 10);
|
|
||||||
|
|
||||||
const body = new TextEncoder().encode(
|
const body = new TextEncoder().encode(
|
||||||
`HTTP/1.1 200 OK\r\nContent-Length: ${
|
`HTTP/1.1 200 OK\r\nContent-Length: ${
|
||||||
Math.round(data.length * 2)
|
Math.round(data.length * 2)
|
||||||
}\r\nTransfer-Encoding: chunked\r\n\r\n${
|
}\r\nTransfer-Encoding: chunked\r\n\r\n${
|
||||||
data.length.toString(16)
|
data.length.toString(16)
|
||||||
}\r\n${data}\r\n0\r\n\r\n`,
|
}\r\n${data}\r\n0\r\n\r\n`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// if transfer-encoding is sent, content-length is ignored
|
// if transfer-encoding is sent, content-length is ignored
|
||||||
// even if it has an invalid value (content-length > totalLength)
|
// even if it has an invalid value (content-length > totalLength)
|
||||||
const listener = invalidServer(addr, body);
|
const listener = invalidServer(addr, body);
|
||||||
const response = await fetch(`http://${addr}/`);
|
const response = await fetch(`http://${addr}/`);
|
||||||
|
|
||||||
const res = await response.arrayBuffer();
|
const res = await response.arrayBuffer();
|
||||||
const buf = new TextEncoder().encode(data);
|
const buf = new TextEncoder().encode(data);
|
||||||
assertEquals(res.byteLength, buf.byteLength);
|
assertEquals(res.byteLength, buf.byteLength);
|
||||||
assertEquals(new Uint8Array(res), buf);
|
assertEquals(new Uint8Array(res), buf);
|
||||||
|
|
||||||
listener.close();
|
listener.close();
|
||||||
},
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { net: true } },
|
// TODO(bartlomieju): reenable this test
|
||||||
|
// https://github.com/denoland/deno/issues/18350
|
||||||
|
{ ignore: Deno.build.os === "windows", permissions: { net: true } },
|
||||||
async function fetchWithInvalidContentLength(): Promise<
|
async function fetchWithInvalidContentLength(): Promise<
|
||||||
void
|
void
|
||||||
> {
|
> {
|
||||||
|
@ -1867,7 +1848,9 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { net: true } },
|
// TODO(bartlomieju): reenable this test
|
||||||
|
// https://github.com/denoland/deno/issues/18350
|
||||||
|
{ ignore: Deno.build.os === "windows", permissions: { net: true } },
|
||||||
async function fetchRequestBodyErrorCatchable() {
|
async function fetchRequestBodyErrorCatchable() {
|
||||||
const listener = Deno.listen({ hostname: "127.0.0.1", port: 4514 });
|
const listener = Deno.listen({ hostname: "127.0.0.1", port: 4514 });
|
||||||
const server = (async () => {
|
const server = (async () => {
|
||||||
|
|
Loading…
Reference in a new issue