balena-settings-storage
Advanced tools
Comparing version 7.0.0-raise-eacces-errors-71a847e518359383968adbe1311a08b45853c61c to 7.0.0-raise-eacces-errors-c83037fe708d2911ce69c70ab00e551fc5296fd4
@@ -8,3 +8,3 @@ # Change Log | ||
# v7.0.0 | ||
## (2020-10-26) | ||
## (2020-11-02) | ||
@@ -11,0 +11,0 @@ * 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] |
{ | ||
"name": "balena-settings-storage", | ||
"version": "7.0.0-raise-eacces-errors-71a847e518359383968adbe1311a08b45853c61c", | ||
"version": "7.0.0-raise-eacces-errors-c83037fe708d2911ce69c70ab00e551fc5296fd4", | ||
"description": "Balena settings storage utilities", | ||
@@ -5,0 +5,0 @@ "main": "build/storage.js", |
@@ -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 @@ }); |
57475
964