Skip to content

Commit

Permalink
chore: use a local instead of remote file for test
Browse files Browse the repository at this point in the history
I was able to replicate the same behavior from #332 by piping a readable
stream with a `highWaterMark` of 1 to extract. I confirmed this test
still failed without the fixes from #332 and now passes.
  • Loading branch information
lukekarrys committed Oct 27, 2022
1 parent 57493ee commit 341e750
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/extract.js
Expand Up @@ -11,7 +11,6 @@ const { promisify } = require('util')
const rimraf = promisify(require('rimraf'))
const mutateFS = require('mutate-fs')
const pipeline = promisify(require('stream').pipeline)
const https = require('https')

t.teardown(_ => rimraf(extractdir))

Expand Down Expand Up @@ -57,6 +56,7 @@ t.test('basic extracting', t => {
})

t.test('ensure an open stream is not prematuraly closed', t => {
t.plan(1)
const dir = path.resolve(extractdir, 'basic-with-stream')

t.beforeEach(async () => {
Expand All @@ -65,18 +65,19 @@ t.test('ensure an open stream is not prematuraly closed', t => {
})

const check = async t => {
fs.lstatSync(dir + '/node-tar-main/LICENSE')
t.ok(fs.lstatSync(dir + '/long-path'))
await rimraf(dir)
t.end()
}

t.test('async promisey', t => {
https.get('https://codeload.github.com/npm/node-tar/tar.gz/main', (stream) => {
return pipeline(
stream,
x({ cwd: dir }, ['node-tar-main/LICENSE'])
).then(_ => check(t))
const stream = fs.createReadStream(path.resolve(tars, 'long-paths.tar'), {
highWaterMark: 1,
})
pipeline(
stream,
x({ cwd: dir })
).then(_ => check(t))
})

t.end()
Expand Down

0 comments on commit 341e750

Please sign in to comment.