@dxos/random-access-storage 0.3.11-main.fbbdc2a → 0.3.11-main.fc97a54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -139,6 +139,36 @@ export const storageTests = (testGroupName: StorageType, createStorage: () => St
139
139
  }
140
140
  });
141
141
 
142
+ test('double destroy file', async function () {
143
+ if (testGroupName !== StorageType.NODE) {
144
+ this.skip();
145
+ }
146
+ const fileName = randomText();
147
+ let firstHandle: File;
148
+ let secondHandle: File;
149
+
150
+ {
151
+ const storage = createStorage();
152
+ const directory = storage.createDirectory();
153
+ const file = directory.getOrCreateFile(fileName);
154
+ const buffer = Buffer.from(randomText());
155
+ await writeAndCheck(file, buffer);
156
+ firstHandle = file;
157
+ }
158
+
159
+ {
160
+ const storage = createStorage();
161
+ const directory = storage.createDirectory();
162
+ const file = directory.getOrCreateFile(fileName);
163
+ const buffer = Buffer.from(randomText());
164
+ await writeAndCheck(file, buffer);
165
+ secondHandle = file;
166
+ }
167
+
168
+ await firstHandle.destroy();
169
+ await expect(secondHandle.destroy()).to.be.rejected;
170
+ });
171
+
142
172
  test('sub-directories', async () => {
143
173
  // 1. Create storage and two subdirectories
144
174
  const storage = createStorage();
@@ -285,7 +315,7 @@ export const storageTests = (testGroupName: StorageType, createStorage: () => St
285
315
  });
286
316
 
287
317
  test('list all files after reopen', async function () {
288
- if (testGroupName !== StorageType.WEBFS) {
318
+ if (testGroupName !== StorageType.WEBFS && testGroupName !== StorageType.NODE) {
289
319
  this.skip();
290
320
  }
291
321
 
@@ -317,5 +347,20 @@ export const storageTests = (testGroupName: StorageType, createStorage: () => St
317
347
  expect(entries.length).to.equal(files.length);
318
348
  }
319
349
  });
350
+
351
+ test('list returns correct filenames', async () => {
352
+ const FILES = ['one', 'two', 'three'];
353
+
354
+ // Create storage and check.
355
+ const storage = createStorage();
356
+ const directory = storage.createDirectory('dir');
357
+
358
+ for (const file of FILES) {
359
+ directory.getOrCreateFile(file);
360
+ }
361
+ await directory.flush();
362
+ const entries = await directory.list();
363
+ expect(entries).to.contain.members(FILES);
364
+ });
320
365
  });
321
366
  };