diff options
author | Myles Borins <mylesborins@github.com> | 2020-10-02 17:52:19 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@github.com> | 2020-10-07 09:59:49 -0400 |
commit | 2e545249557c265f7d5f338cc3a382985211603c (patch) | |
tree | a18ca49252a58cc5a80cd438a020a99bf48a8d23 /deps/npm/node_modules/fs-write-stream-atomic/test/basic.js | |
parent | 14699846452e627f97dedb85991eea67d932a79d (diff) | |
download | node-new-2e545249557c265f7d5f338cc3a382985211603c.tar.gz |
deps: update npm to 7.0.0-rc.3
PR-URL: https://github.com/nodejs/node/pull/35474
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/fs-write-stream-atomic/test/basic.js')
-rw-r--r-- | deps/npm/node_modules/fs-write-stream-atomic/test/basic.js | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/deps/npm/node_modules/fs-write-stream-atomic/test/basic.js b/deps/npm/node_modules/fs-write-stream-atomic/test/basic.js deleted file mode 100644 index d0205e15f4..0000000000 --- a/deps/npm/node_modules/fs-write-stream-atomic/test/basic.js +++ /dev/null @@ -1,97 +0,0 @@ -var fs = require('graceful-fs') -var test = require('tap').test -var path = require('path') -var writeStream = require('../index.js') - -var rename = fs.rename -fs.rename = function (from, to, cb) { - setTimeout(function () { - rename(from, to, cb) - }, 100) -} - -test('basic', function (t) { - // open 10 write streams to the same file. - // then write to each of them, and to the target - // and verify at the end that each of them does their thing - var target = path.resolve(__dirname, 'test.txt') - var n = 10 - - // We run all of our assertions twice: - // once for finish, once for close - // There are 6 assertions, two fixed, plus 4 lines in the file. - t.plan(n * 2 * 6) - - var streams = [] - for (var i = 0; i < n; i++) { - var s = writeStream(target) - s.on('finish', verifier('finish', i)) - s.on('close', verifier('close', i)) - streams.push(s) - } - - function verifier (ev, num) { - return function () { - if (ev === 'close') { - t.equal(this.__emittedFinish, true, num + '. closed only after finish') - } else { - this.__emittedFinish = true - t.equal(ev, 'finish', num + '. finished') - } - - // make sure that one of the atomic streams won. - var res = fs.readFileSync(target, 'utf8') - var lines = res.trim().split(/\n/) - lines.forEach(function (line, lineno) { - var first = lines[0].match(/\d+$/)[0] - var cur = line.match(/\d+$/)[0] - t.equal(cur, first, num + '. line ' + lineno + ' matches') - }) - - var resExpr = /^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/ - t.similar(res, resExpr, num + '. content matches') - } - } - - // now write something to each stream. - streams.forEach(function (stream, i) { - stream.write('first write ' + i + '\n') - }) - - // wait a sec for those writes to go out. - setTimeout(function () { - // write something else to the target. - fs.writeFileSync(target, 'brutality!\n') - - // write some more stuff. - streams.forEach(function (stream, i) { - stream.write('second write ' + i + '\n') - }) - - setTimeout(function () { - // Oops! Deleted the file! - fs.unlinkSync(target) - - // write some more stuff. - streams.forEach(function (stream, i) { - stream.write('third write ' + i + '\n') - }) - - setTimeout(function () { - fs.writeFileSync(target, 'brutality TWO!\n') - streams.forEach(function (stream, i) { - stream.end('final write ' + i + '\n') - }) - }, 50) - }, 50) - }, 50) -}) - -test('cleanup', function (t) { - fs.readdirSync(__dirname).filter(function (f) { - return f.match(/^test.txt/) - }).forEach(function (file) { - fs.unlinkSync(path.resolve(__dirname, file)) - }) - t.end() -}) |