balena-settings-storage
Advanced tools
Comparing version 7.0.0-raise-eacces-errors-71a847e518359383968adbe1311a08b45853c61c to 7.0.0-raise-eacces-errors-900b207510823753605bc38fbeb69db4d20d3c73
@@ -8,4 +8,5 @@ # Change Log | ||
# v7.0.0 | ||
## (2020-10-26) | ||
## (2020-11-03) | ||
* Rebuild README.md [Paulo Castro] | ||
* Remove package-lock.json because it is not recommended for libraries 'package-lock.json' cannot be published to the npm registry, and will be ignored when npm-installed by packages that depend on resin-multibuild. This can lead to dependency-related errors being masked when resin-multibuild is tested in isolation. Reference: https://docs.npmjs.com/files/package-lock.json [josecoelho] | ||
@@ -12,0 +13,0 @@ * Change to raise error when file has no permission [josecoelho] |
{ | ||
"name": "balena-settings-storage", | ||
"version": "7.0.0-raise-eacces-errors-71a847e518359383968adbe1311a08b45853c61c", | ||
"version": "7.0.0-raise-eacces-errors-900b207510823753605bc38fbeb69db4d20d3c73", | ||
"description": "Balena settings storage utilities", | ||
@@ -38,6 +38,6 @@ "main": "build/storage.js", | ||
"@types/mocha": "^2.2.41", | ||
"balena-config-karma": "^2.0.0", | ||
"balena-config-karma": "^3.0.0", | ||
"balena-settings-client": "^4.0.0", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"karma": "^1.7.0", | ||
"karma": "^5.2.3", | ||
"mocha": "^3.5.0", | ||
@@ -44,0 +44,0 @@ "mochainon": "^2.0.0", |
@@ -128,20 +128,31 @@ import * as BalenaSettingsClientModule from 'balena-settings-client'; | ||
let fooPath: string; | ||
beforeEach(() => { | ||
fooPath = path.join(dataDirectory!, 'foo'); | ||
fs.writeFileSync(fooPath, 'hello world'); | ||
}); | ||
describe('with expected file access', () => { | ||
let fooPath: string; | ||
beforeEach(() => { | ||
fooPath = path.join(dataDirectory!, 'foo'); | ||
fs.writeFileSync(fooPath, 'hello world'); | ||
}); | ||
afterEach(() => { | ||
fs.unlinkSync(fooPath); | ||
afterEach(() => { | ||
fs.unlinkSync(fooPath); | ||
}); | ||
it('should be able to read back', () => | ||
m.chai.expect(storage.get('foo')).to.eventually.equal('hello world')); | ||
}); | ||
it('should be able to read back', () => | ||
m.chai.expect(storage.get('foo')).to.eventually.equal('hello world')); | ||
describe('with no read access', () => { | ||
let fsReadFileStub: any; | ||
beforeEach(() => { | ||
fsReadFileStub = m.sinon.stub(fs.promises, 'readFile'); | ||
fsReadFileStub.rejects({ code: 'EACCES' }); | ||
}); | ||
describe('with no read access', () => { | ||
afterEach(() => { | ||
fsReadFileStub.restore(); | ||
}); | ||
it('should raise an error', () => { | ||
fs.chmodSync(fooPath, '333'); | ||
return m.chai | ||
.expect(storage.get('foo')) | ||
.expect(storage.get('bar')) | ||
.to.eventually.be.rejectedWith(BalenaSettingsPermissionError); | ||
@@ -148,0 +159,0 @@ }); |
57510
964