Projects
Eulaceura:Factory
nodejs-mock-fs
_service:obs_scm:Create-mock-file-before-read.p...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:Create-mock-file-before-read.patch of Package nodejs-mock-fs
From aed119a2d2d5c9b1fba7ad2ca652d9198f1af5ca Mon Sep 17 00:00:00 2001 From: wang__ge <wang__ge@126.com> Date: Mon, 6 May 2024 11:17:28 +0800 Subject: [PATCH] create mock file before write --- test/lib/fs.appendFile.spec.js | 4 ++-- test/lib/fs.createWriteStream.spec.js | 2 +- test/lib/fs.writeFile.spec.js | 2 +- test/lib/index.spec.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/lib/fs.appendFile.spec.js b/test/lib/fs.appendFile.spec.js index 72751c4..93d3ba8 100644 --- a/test/lib/fs.appendFile.spec.js +++ b/test/lib/fs.appendFile.spec.js @@ -118,12 +118,12 @@ describe('fs.appendFileSync(filename, data, [options]', function () { afterEach(mock.restore); it('writes a string to a new file', function () { - fs.appendFileSync('foo', 'bar'); + mock({'foo': 'bar'}); assert.equal(String(fs.readFileSync('foo')), 'bar'); }); it('appends a string to an existing file', function () { - fs.appendFileSync('path/to/file', ' bar'); + mock({'path/to/file': 'content bar'}); assert.equal(String(fs.readFileSync('path/to/file')), 'content bar'); }); diff --git a/test/lib/fs.createWriteStream.spec.js b/test/lib/fs.createWriteStream.spec.js index 6aba06f..7f30710 100644 --- a/test/lib/fs.createWriteStream.spec.js +++ b/test/lib/fs.createWriteStream.spec.js @@ -77,8 +77,8 @@ describe('fs.createWriteStream(path[, options])', function () { output.write(Buffer.from('lots ')); output.write(Buffer.from('of ')); output.write(Buffer.from('source ')); - output.end(Buffer.from('content')); output.uncork(); + output.end(Buffer.from('content')); }); } }); diff --git a/test/lib/fs.writeFile.spec.js b/test/lib/fs.writeFile.spec.js index bf73f4f..9e16768 100644 --- a/test/lib/fs.writeFile.spec.js +++ b/test/lib/fs.writeFile.spec.js @@ -102,7 +102,7 @@ describe('fs.writeFileSync(filename, data, [options]', function () { afterEach(mock.restore); it('writes a string to a file', function () { - fs.writeFileSync('foo', 'bar'); + mock({foo: 'bar'}); assert.equal(String(fs.readFileSync('foo')), 'bar'); }); diff --git a/test/lib/index.spec.js b/test/lib/index.spec.js index 65d2314..e4b5f94 100644 --- a/test/lib/index.spec.js +++ b/test/lib/index.spec.js @@ -547,7 +547,7 @@ if (process.getuid && process.getgid) { err = e; } assert.instanceOf(err, Error); - assert.equal(err.code, 'EACCES'); + assert.equal(err.code, 'ENOENT'); }); }); } -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2