Skip to content

Commit

Permalink
refactor: close file descriptors in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Mar 17, 2022
1 parent 1b86503 commit f15a73e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/core/src/__test__/tar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ o.spec('TarReader', () => {
const buf = Buffer.alloc(tarTest?.size ?? 0);
await source.read(buf, 0, tarTest?.size, tarTest?.offset);
o(buf.toString().startsWith(`/** Start Header */`)).equals(true);

await source.close();
});

o('should work with a .tar.co', async () => {
Expand All @@ -78,5 +80,7 @@ o.spec('TarReader', () => {
o(data).notEquals(null);
const buf = Buffer.from(data!.slice(0, 100));
o(buf.toString().startsWith(`/** Start Header */`)).equals(true);

await cotar.source.close?.();
});
});
1 change: 0 additions & 1 deletion packages/core/src/binary/__test__/binary.header.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ o.spec('CotarBinaryHeaderFooter', () => {
writeHeaderFooter(buf, Example.v2.header.count);

const buf64 = buf.toString('base64');
console.log(buf64);
// Should start and end with the same data
o(buf64.startsWith('Q09UAtIClkk')).equals(true);
o(buf64.endsWith('Q09UAtIClkk=')).equals(true);
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/binary/__test__/binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ o.spec('CotarBinary', () => {

// Should validate
await TarReader.validate(fd, index);
await fd.close();
await source.close?.();
await sourceIndex.close?.();
});
});

Expand Down

0 comments on commit f15a73e

Please sign in to comment.