diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-24 10:27:29 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 00:27:29 +0100 |
commit | 947ce41e99637dae4cf46126b8bb2d4107fb9913 (patch) | |
tree | 094cdca89b38d358bb801702b4caf5dcb6374c80 /cli/tests/unit_node/_fs/_fs_appendFile_test.ts | |
parent | 4eedac3604dad9f366d28868077eb02eddc22661 (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_node/_fs/_fs_appendFile_test.ts')
-rw-r--r-- | cli/tests/unit_node/_fs/_fs_appendFile_test.ts | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_appendFile_test.ts b/cli/tests/unit_node/_fs/_fs_appendFile_test.ts index 33c99414f..e70d3401f 100644 --- a/cli/tests/unit_node/_fs/_fs_appendFile_test.ts +++ b/cli/tests/unit_node/_fs/_fs_appendFile_test.ts @@ -97,7 +97,6 @@ Deno.test({ Deno.test({ name: "Async: Data is written to passed in file path", async fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); await new Promise<void>((resolve, reject) => { appendFile("_fs_appendFile_test_file.txt", "hello world", (err) => { if (err) reject(err); @@ -105,7 +104,6 @@ Deno.test({ }); }) .then(async () => { - assertEquals(Deno.resources(), openResourcesBeforeAppend); const data = await Deno.readFile("_fs_appendFile_test_file.txt"); assertEquals(decoder.decode(data), "hello world"); }, (err) => { @@ -120,7 +118,6 @@ Deno.test({ Deno.test({ name: "Async: Data is written to passed in URL", async fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); const fileURL = new URL("_fs_appendFile_test_file.txt", import.meta.url); await new Promise<void>((resolve, reject) => { appendFile(fileURL, "hello world", (err) => { @@ -129,7 +126,6 @@ Deno.test({ }); }) .then(async () => { - assertEquals(Deno.resources(), openResourcesBeforeAppend); const data = await Deno.readFile(fromFileUrl(fileURL)); assertEquals(decoder.decode(data), "hello world"); }, (err) => { @@ -145,7 +141,6 @@ Deno.test({ name: "Async: Callback is made with error if attempting to append data to an existing file with 'ax' flag", async fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); const tempFile: string = await Deno.makeTempFile(); await new Promise<void>((resolve, reject) => { appendFile(tempFile, "hello world", { flag: "ax" }, (err) => { @@ -153,11 +148,8 @@ Deno.test({ else resolve(); }); }) - .then(() => { - fail("Expected error to be thrown"); - }, () => { - assertEquals(Deno.resources(), openResourcesBeforeAppend); - }) + .then(() => fail("Expected error to be thrown")) + .catch(() => {}) .finally(async () => { await Deno.remove(tempFile); }); @@ -184,9 +176,7 @@ Deno.test({ Deno.test({ name: "Sync: Data is written to passed in file path", fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); appendFileSync("_fs_appendFile_test_file_sync.txt", "hello world"); - assertEquals(Deno.resources(), openResourcesBeforeAppend); const data = Deno.readFileSync("_fs_appendFile_test_file_sync.txt"); assertEquals(decoder.decode(data), "hello world"); Deno.removeSync("_fs_appendFile_test_file_sync.txt"); @@ -197,14 +187,12 @@ Deno.test({ name: "Sync: error thrown if attempting to append data to an existing file with 'ax' flag", fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); const tempFile: string = Deno.makeTempFileSync(); assertThrows( () => appendFileSync(tempFile, "hello world", { flag: "ax" }), Error, "", ); - assertEquals(Deno.resources(), openResourcesBeforeAppend); Deno.removeSync(tempFile); }, }); @@ -212,10 +200,8 @@ Deno.test({ Deno.test({ name: "Sync: Data is written in Uint8Array to passed in file path", fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); const testData = new TextEncoder().encode("hello world"); appendFileSync("_fs_appendFile_test_file_sync.txt", testData); - assertEquals(Deno.resources(), openResourcesBeforeAppend); const data = Deno.readFileSync("_fs_appendFile_test_file_sync.txt"); assertEquals(data, testData); Deno.removeSync("_fs_appendFile_test_file_sync.txt"); @@ -225,7 +211,6 @@ Deno.test({ Deno.test({ name: "Async: Data is written in Uint8Array to passed in file path", async fn() { - const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); const testData = new TextEncoder().encode("hello world"); await new Promise<void>((resolve, reject) => { appendFile("_fs_appendFile_test_file.txt", testData, (err) => { @@ -234,7 +219,6 @@ Deno.test({ }); }) .then(async () => { - assertEquals(Deno.resources(), openResourcesBeforeAppend); const data = await Deno.readFile("_fs_appendFile_test_file.txt"); assertEquals(data, testData); }, (err) => { |