summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-01-24 10:27:29 +1100
committerGitHub <noreply@github.com>2024-01-24 00:27:29 +0100
commit947ce41e99637dae4cf46126b8bb2d4107fb9913 (patch)
tree094cdca89b38d358bb801702b4caf5dcb6374c80 /cli/tests/unit
parent4eedac3604dad9f366d28868077eb02eddc22661 (diff)
feat: deprecate `Deno.resources()` (#22059)
Most uses of `Deno.resources()` within tests, as they previously checked for leaked resources. This is not needed as the test runner does this automatically. Other internal uses of this API have been replaced with the internal `Deno[Deno.internal].core.resources()`.
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/http_test.ts14
-rw-r--r--cli/tests/unit/read_file_test.ts4
-rw-r--r--cli/tests/unit/read_text_file_test.ts4
3 files changed, 3 insertions, 19 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index acdaef903..a7f34f0ac 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -1084,6 +1084,9 @@ Deno.test(
);
// https://github.com/denoland/deno/issues/11926
+// verify that the only new resource is "httpConnection", to make
+// sure "request" resource is closed even if its body was not read
+// by server handler
Deno.test(
{ permissions: { net: true } },
async function httpServerDoesntLeakResources2() {
@@ -1105,22 +1108,11 @@ Deno.test(
}
})();
- const resourcesBefore = Deno.resources();
const response = await fetch(`http://127.0.0.1:${listenPort}`, {
method: "POST",
body: "hello world",
});
await response.text();
- const resourcesAfter = Deno.resources();
- // verify that the only new resource is "httpConnection", to make
- // sure "request" resource is closed even if its body was not read
- // by server handler
-
- for (const rid of Object.keys(resourcesBefore)) {
- delete resourcesAfter[Number(rid)];
- }
-
- assertEquals(Object.keys(resourcesAfter).length, 1);
listener!.close();
httpConn!.close();
diff --git a/cli/tests/unit/read_file_test.ts b/cli/tests/unit/read_file_test.ts
index 6f5392ff4..24ec1aedc 100644
--- a/cli/tests/unit/read_file_test.ts
+++ b/cli/tests/unit/read_file_test.ts
@@ -75,18 +75,14 @@ Deno.test({ permissions: { read: true } }, function readFileSyncLoop() {
Deno.test(
{ permissions: { read: true } },
async function readFileDoesNotLeakResources() {
- const resourcesBefore = Deno.resources();
await assertRejects(async () => await Deno.readFile("cli"));
- assertEquals(resourcesBefore, Deno.resources());
},
);
Deno.test(
{ permissions: { read: true } },
function readFileSyncDoesNotLeakResources() {
- const resourcesBefore = Deno.resources();
assertThrows(() => Deno.readFileSync("cli"));
- assertEquals(resourcesBefore, Deno.resources());
},
);
diff --git a/cli/tests/unit/read_text_file_test.ts b/cli/tests/unit/read_text_file_test.ts
index 7f5383059..5a64522af 100644
--- a/cli/tests/unit/read_text_file_test.ts
+++ b/cli/tests/unit/read_text_file_test.ts
@@ -73,18 +73,14 @@ Deno.test({ permissions: { read: true } }, function readTextFileSyncLoop() {
Deno.test(
{ permissions: { read: true } },
async function readTextFileDoesNotLeakResources() {
- const resourcesBefore = Deno.resources();
await assertRejects(async () => await Deno.readTextFile("cli"));
- assertEquals(resourcesBefore, Deno.resources());
},
);
Deno.test(
{ permissions: { read: true } },
function readTextFileSyncDoesNotLeakResources() {
- const resourcesBefore = Deno.resources();
assertThrows(() => Deno.readTextFileSync("cli"));
- assertEquals(resourcesBefore, Deno.resources());
},
);