diff options
author | Luca Casonato <hello@lcas.dev> | 2023-11-01 20:26:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 20:26:12 +0100 |
commit | d42f1543121e7245789a96a485d1ef7645cb5fba (patch) | |
tree | d57a10ac527fe5b6796a3a8866af95f0f1a5d7bd /cli/tests/unit/fs_events_test.ts | |
parent | 1d19b1011bd7df50598f5981408c2d78c35b76d2 (diff) |
feat: disposable Deno resources (#20845)
This commit implements Symbol.dispose and Symbol.asyncDispose for
the relevant resources.
Closes #20839
---------
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tests/unit/fs_events_test.ts')
-rw-r--r-- | cli/tests/unit/fs_events_test.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cli/tests/unit/fs_events_test.ts b/cli/tests/unit/fs_events_test.ts index 9330f2007..86adeb4d7 100644 --- a/cli/tests/unit/fs_events_test.ts +++ b/cli/tests/unit/fs_events_test.ts @@ -107,3 +107,33 @@ Deno.test( assertEquals(events, []); }, ); + +Deno.test( + { permissions: { read: true, write: true } }, + async function watchFsExplicitResourceManagement() { + let res; + { + const testDir = await makeTempDir(); + using iter = Deno.watchFs(testDir); + + res = iter[Symbol.asyncIterator]().next(); + } + + const { done } = await res; + assert(done); + }, +); + +Deno.test( + { permissions: { read: true, write: true } }, + async function watchFsExplicitResourceManagementManualClose() { + const testDir = await makeTempDir(); + using iter = Deno.watchFs(testDir); + + const res = iter[Symbol.asyncIterator]().next(); + + iter.close(); + const { done } = await res; + assert(done); + }, +); |