Skip to content

Commit

Permalink
test(snapstore): re-save between prepare and commit delete
Browse files Browse the repository at this point in the history
plus one more /etc/passwd test
  • Loading branch information
dckc committed Jul 29, 2021
1 parent 21a7a91 commit 1b2050d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/swing-store-lmdb/test/test-snapstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ test('snapStore prepare / commit delete is robust', async t => {
// @ts-ignore
t.throws(() => store.prepareToDelete(1));
t.throws(() => store.prepareToDelete('../../../etc/passwd'));
t.throws(() => store.prepareToDelete('/etc/passwd'));

store.prepareToDelete(hashes[2]);
store.commitDeletes();
t.deepEqual(fs.readdirSync(pool.name).length, 4);

// Restore (re-save) between prepare and commit.
store.prepareToDelete(hashes[3]);
await store.save(async fn => fs.promises.writeFile(fn, `file 3`));
store.commitDeletes();
t.true(fs.readdirSync(pool.name).includes(`${hashes[3]}.gz`));

hashes.forEach(store.prepareToDelete);
store.prepareToDelete('does not exist');
t.throws(() => store.commitDeletes());
Expand Down

0 comments on commit 1b2050d

Please sign in to comment.