From 341e750221d2a3a910a3e40fe441197283fc0510 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 27 Oct 2022 09:06:53 -0700 Subject: [PATCH] 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. --- test/extract.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/extract.js b/test/extract.js index 5bbffeec..fbeec1e4 100644 --- a/test/extract.js +++ b/test/extract.js @@ -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)) @@ -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 () => { @@ -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()