Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 341e750

Browse files
committed
chore: use a local instead of remote file for test
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.
1 parent 57493ee commit 341e750

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/extract.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const { promisify } = require('util')
1111
const rimraf = promisify(require('rimraf'))
1212
const mutateFS = require('mutate-fs')
1313
const pipeline = promisify(require('stream').pipeline)
14-
const https = require('https')
1514

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

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

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

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

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

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

8283
t.end()

0 commit comments

Comments
 (0)