From 9b721d83dc9176efb9b422bcc68433fc56512408 Mon Sep 17 00:00:00 2001 From: Jonas Hermsmeier Date: Fri, 5 Jan 2018 17:22:00 +0100 Subject: [PATCH] upgrade(package): Update drivelist 5.2.12 -> 6.0.0 (#1953) * upgrade(package): Update drivelist 5.2.12 -> 6.0.0 This updates `drivelist` to incorporate the new native bindings rewrite on Windows, fixing scanning errors. Change-Type: patch Changelog Entry: Fix "Couldn't scan drives" error * test(drive-selection): Adjust to breaking drivelist changes * fix(drivelist): Correct conditions in standard adapter * refactor(usbboot): Adjust readonly & system flags * doc(drive-constraints): protected -> isReadonly --- lib/shared/drive-constraints.js | 12 +- lib/shared/messages.js | 4 +- lib/shared/sdk/standard/index.js | 10 +- lib/shared/sdk/usbboot/index.js | 8 +- lib/shared/store.js | 2 +- npm-shrinkwrap.json | 40 +++- package.json | 2 +- tests/gui/modules/drive-scanner.spec.js | 216 +++++++++++-------- tests/shared/drive-constraints.spec.js | 72 +++---- tests/shared/models/available-drives.spec.js | 146 ++++++++----- tests/shared/models/selection-state.spec.js | 48 +++-- 11 files changed, 345 insertions(+), 215 deletions(-) diff --git a/lib/shared/drive-constraints.js b/lib/shared/drive-constraints.js index a47ef4e6..70277d8c 100644 --- a/lib/shared/drive-constraints.js +++ b/lib/shared/drive-constraints.js @@ -43,13 +43,13 @@ const UNKNOWN_SIZE = 0 * device: '/dev/disk2', * name: 'My Drive', * size: 123456789, - * protected: true + * isReadonly: true * })) { * console.log('This drive is locked (e.g: write-protected)'); * } */ exports.isDriveLocked = (drive) => { - return Boolean(_.get(drive, [ 'protected' ], false)) + return Boolean(_.get(drive, [ 'isReadonly' ], false)) } /** @@ -64,14 +64,14 @@ exports.isDriveLocked = (drive) => { * device: '/dev/disk2', * name: 'My Drive', * size: 123456789, - * protected: true, + * isReadonly: true, * system: true * })) { * console.log('This drive is a system drive!'); * } */ exports.isSystemDrive = (drive) => { - return Boolean(_.get(drive, [ 'system' ], false)) + return Boolean(_.get(drive, [ 'isSystem' ], false)) } /** @@ -93,7 +93,7 @@ exports.isSystemDrive = (drive) => { * device: '/dev/disk2', * name: 'My Drive', * size: 123456789, - * protected: true, + * isReadonly: true, * system: true, * mountpoints: [ * { @@ -215,7 +215,7 @@ exports.isDriveDisabled = (drive) => { * device: '/dev/disk2', * name: 'My Drive', * size: 1000000000, - * protected: false + * isReadonly: false * }, { * path: 'rpi.img', * size: { diff --git a/lib/shared/messages.js b/lib/shared/messages.js index 6dadf11a..d9eec17d 100644 --- a/lib/shared/messages.js +++ b/lib/shared/messages.js @@ -34,7 +34,7 @@ module.exports = { flashComplete: _.template([ '<%= imageBasename %> was successfully written to', - '<%= drive.description %> (<%= drive.displayName %>)' + '<%= drive.description %> (<%= drive.raw %>)' ].join(' ')) }, @@ -102,7 +102,7 @@ module.exports = { flashFailure: _.template([ 'Something went wrong while writing <%= imageBasename %>', - 'to <%= drive.description %> (<%= drive.displayName %>)' + 'to <%= drive.description %> (<%= drive.raw %>)' ].join(' ')), driveUnplugged: _.template([ diff --git a/lib/shared/sdk/standard/index.js b/lib/shared/sdk/standard/index.js index 0cc9a6e7..c7f6e8cb 100644 --- a/lib/shared/sdk/standard/index.js +++ b/lib/shared/sdk/standard/index.js @@ -71,7 +71,7 @@ class StandardAdapter extends EventEmitter { if (_.includes([ '0001', 'RPi-MSD- 0001', 'File-Stor Gadget', 'Linux File-Stor Gadget USB Device' ], drive.description)) { drive.description = 'Compute Module' drive.icon = 'raspberrypi' - drive.system = false + drive.isSystem = false } return drive @@ -79,7 +79,13 @@ class StandardAdapter extends EventEmitter { this.emit('error', error) callback && callback(error) }).filter((drive) => { - return options.includeSystemDrives || !drive.system + return !drive.error && (options.includeSystemDrives || !drive.isSystem) + }).map((drive) => { + drive.displayName = drive.device + if (/PhysicalDrive/i.test(drive.device) && drive.mountpoints.length) { + drive.displayName = _.map(drive.mountpoints, 'path').join(', ') + } + return drive }).then((drives) => { this.emit('devices', drives) callback && callback(null, drives) diff --git a/lib/shared/sdk/usbboot/index.js b/lib/shared/sdk/usbboot/index.js index 584a347f..8f5b7933 100644 --- a/lib/shared/sdk/usbboot/index.js +++ b/lib/shared/sdk/usbboot/index.js @@ -269,8 +269,8 @@ class USBBootAdapter extends EventEmitter { displayName: 'Missing drivers', description, mountpoints: [], - protected: false, - system: false, + isReadonly: false, + isSystem: false, disabled: true, icon: 'warning', size: null, @@ -292,8 +292,8 @@ class USBBootAdapter extends EventEmitter { size: null, mountpoints: [], - protected: false, - system: false, + isReadonly: false, + isSystem: false, disabled: true, icon: 'loading', vendor: usbIdToString(device.deviceDescriptor.idVendor), diff --git a/lib/shared/store.js b/lib/shared/store.js index 96322dd1..b05cd2dd 100644 --- a/lib/shared/store.js +++ b/lib/shared/store.js @@ -298,7 +298,7 @@ const storeReducer = (state = DEFAULT_STATE, action) => { }) } - if (selectedDrive.get('protected')) { + if (selectedDrive.get('isReadonly')) { throw errors.createError({ title: 'The drive is write-protected' }) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d7f943a0..a244fe52 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1296,8 +1296,8 @@ "dev": true }, "drivelist": { - "version": "5.2.12", - "resolved": "https://registry.npmjs.org/drivelist/-/drivelist-5.2.12.tgz", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/drivelist/-/drivelist-6.0.0.tgz", "dependencies": { "bindings": { "version": "1.3.0", @@ -5171,13 +5171,49 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/resin-cli-visuals/-/resin-cli-visuals-1.3.1.tgz", "dependencies": { + "bindings": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz" + }, "bluebird": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz" }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz" + }, + "drivelist": { + "version": "5.2.12", + "resolved": "https://registry.npmjs.org/drivelist/-/drivelist-5.2.12.tgz" + }, + "esprima": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz" + }, + "js-yaml": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz" + }, "lodash": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" + }, + "nan": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz" + }, + "prebuild-install": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.4.1.tgz" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" } } }, diff --git a/package.json b/package.json index 56b7081d..238cd4f7 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "command-join": "2.0.0", "crc32-stream": "2.0.0", "debug": "2.6.8", - "drivelist": "5.2.12", + "drivelist": "6.0.0", "electron-is-running-in-asar": "1.0.0", "file-type": "4.1.0", "flexboxgrid": "6.3.0", diff --git a/tests/gui/modules/drive-scanner.spec.js b/tests/gui/modules/drive-scanner.spec.js index 548cacac..c0eb76a5 100644 --- a/tests/gui/modules/drive-scanner.spec.js +++ b/tests/gui/modules/drive-scanner.spec.js @@ -27,11 +27,16 @@ describe('Browser: driveScanner', function () { const spy = m.sinon.spy() driveScanner.once('devices', function (drives) { - m.chai.expect(drives).to.be.an.instanceof(Array) - m.chai.expect(spy).to.not.have.been.called + let error = null + try { + m.chai.expect(drives).to.be.an.instanceof(Array) + m.chai.expect(spy).to.not.have.been.called + } catch (exception) { + error = exception + } driveScanner.removeListener('error', spy) driveScanner.stop() - done() + done(error) }) driveScanner.on('error', spy) @@ -52,7 +57,7 @@ describe('Browser: driveScanner', function () { path: '/' } ], - system: true + isSystem: true } ]) }) @@ -65,11 +70,16 @@ describe('Browser: driveScanner', function () { const spy = m.sinon.spy() driveScanner.once('devices', function (drives) { - m.chai.expect(drives).to.deep.equal([]) - m.chai.expect(spy).to.not.have.been.called + let error = null + try { + m.chai.expect(drives).to.deep.equal([]) + m.chai.expect(spy).to.not.have.been.called + } catch (exception) { + error = exception + } driveScanner.removeListener('error', spy) driveScanner.stop() - done() + done(error) }) driveScanner.on('error', spy) @@ -101,7 +111,8 @@ describe('Browser: driveScanner', function () { path: '/' } ], - system: true + isSystem: true, + isRemovable: false }, { device: '/dev/sdb', @@ -113,7 +124,8 @@ describe('Browser: driveScanner', function () { path: '/mnt/foo' } ], - system: false + isSystem: false, + isRemovable: false }, { device: '/dev/sdc', @@ -125,7 +137,8 @@ describe('Browser: driveScanner', function () { path: '/mnt/bar' } ], - system: false + isSystem: false, + isRemovable: false } ]) }) @@ -138,39 +151,46 @@ describe('Browser: driveScanner', function () { const spy = m.sinon.spy() driveScanner.once('devices', function (drives) { - m.chai.expect(drives).to.deep.equal([ - { - device: '/dev/sdb', - displayName: '/dev/sdb', - description: 'Foo', - size: '14G', - mountpoints: [ - { - path: '/mnt/foo' - } - ], - adapter: 'standard', - system: false - }, - { - device: '/dev/sdc', - displayName: '/dev/sdc', - description: 'Bar', - size: '14G', - mountpoints: [ - { - path: '/mnt/bar' - } - ], - adapter: 'standard', - system: false - } - ]) + let error = null + try { + m.chai.expect(drives).to.deep.equal([ + { + device: '/dev/sdb', + displayName: '/dev/sdb', + description: 'Foo', + size: '14G', + mountpoints: [ + { + path: '/mnt/foo' + } + ], + adapter: 'standard', + isSystem: false, + isRemovable: false + }, + { + device: '/dev/sdc', + displayName: '/dev/sdc', + description: 'Bar', + size: '14G', + mountpoints: [ + { + path: '/mnt/bar' + } + ], + adapter: 'standard', + isSystem: false, + isRemovable: false + } + ]) - m.chai.expect(spy).to.not.have.been.called + m.chai.expect(spy).to.not.have.been.called + } catch (exception) { + error = exception + } driveScanner.removeListener('error', spy) driveScanner.stop() - done() + done(error) }) driveScanner.on('error', spy) @@ -203,7 +223,8 @@ describe('Browser: driveScanner', function () { path: 'C:' } ], - system: true + isSystem: true, + isRemovable: false }, { device: '\\\\.\\PHYSICALDRIVE2', @@ -211,7 +232,8 @@ describe('Browser: driveScanner', function () { description: 'Foo', size: '14G', mountpoints: [], - system: false + isSystem: false, + isRemovable: false }, { device: '\\\\.\\PHYSICALDRIVE3', @@ -223,7 +245,8 @@ describe('Browser: driveScanner', function () { path: 'F:' } ], - system: false + isSystem: false, + isRemovable: false } ]) }) @@ -236,35 +259,41 @@ describe('Browser: driveScanner', function () { const spy = m.sinon.spy() driveScanner.once('devices', function (drives) { - m.chai.expect(drives).to.deep.equal([ - { - device: '\\\\.\\PHYSICALDRIVE2', - displayName: '\\\\.\\PHYSICALDRIVE2', - description: 'Foo', - size: '14G', - mountpoints: [], - adapter: 'standard', - system: false - }, - { - device: '\\\\.\\PHYSICALDRIVE3', - displayName: 'F:', - description: 'Bar', - size: '14G', - mountpoints: [ - { - path: 'F:' - } - ], - adapter: 'standard', - system: false - } - ]) - - m.chai.expect(spy).to.not.have.been.called + let error = null + try { + m.chai.expect(drives).to.deep.equal([ + { + device: '\\\\.\\PHYSICALDRIVE2', + displayName: '\\\\.\\PHYSICALDRIVE2', + description: 'Foo', + size: '14G', + mountpoints: [], + adapter: 'standard', + isSystem: false, + isRemovable: false + }, + { + device: '\\\\.\\PHYSICALDRIVE3', + displayName: 'F:', + description: 'Bar', + size: '14G', + mountpoints: [ + { + path: 'F:' + } + ], + adapter: 'standard', + isSystem: false, + isRemovable: false + } + ]) + m.chai.expect(spy).to.not.have.been.called + } catch (exception) { + error = exception + } driveScanner.removeListener('error', spy) driveScanner.stop() - done() + done(error) }) driveScanner.on('error', spy) @@ -278,7 +307,7 @@ describe('Browser: driveScanner', function () { this.drivelistStub.yields(null, [ { device: '\\\\.\\PHYSICALDRIVE3', - displayName: 'F:', + raw: '\\\\.\\PHYSICALDRIVE3', description: 'Bar', size: '14G', mountpoints: [ @@ -286,7 +315,8 @@ describe('Browser: driveScanner', function () { path: 'F:' } ], - system: false + isSystem: false, + isRemovable: true } ]) }) @@ -299,12 +329,17 @@ describe('Browser: driveScanner', function () { const spy = m.sinon.spy() driveScanner.once('devices', function (drives) { - m.chai.expect(drives).to.have.length(1) - m.chai.expect(drives[0].displayName).to.equal('F:') - m.chai.expect(spy).to.not.have.been.called + let error = null + try { + m.chai.expect(drives).to.have.length(1) + m.chai.expect(drives[0].displayName).to.equal('F:') + m.chai.expect(spy).to.not.have.been.called + } catch (exception) { + error = exception + } driveScanner.removeListener('error', spy) driveScanner.stop() - done() + done(error) }) driveScanner.on('error', spy) @@ -318,7 +353,7 @@ describe('Browser: driveScanner', function () { this.drivesListStub.yields(null, [ { device: '\\\\.\\PHYSICALDRIVE3', - displayName: 'F:, G:, H:', + raw: '\\\\.\\PHYSICALDRIVE3', description: 'Bar', size: '14G', mountpoints: [ @@ -332,7 +367,8 @@ describe('Browser: driveScanner', function () { path: 'H:' } ], - system: false + isSystem: false, + isRemovable: true } ]) }) @@ -345,12 +381,17 @@ describe('Browser: driveScanner', function () { const spy = m.sinon.spy() driveScanner.once('devices', function (drives) { - m.chai.expect(drives).to.have.length(1) - m.chai.expect(drives[0].displayName).to.equal('F:, G:, H:') - m.chai.expect(spy).to.not.have.been.called + let error = null + try { + m.chai.expect(drives).to.have.length(1) + m.chai.expect(drives[0].displayName).to.equal('F:, G:, H:') + m.chai.expect(spy).to.not.have.been.called + } catch (exception) { + error = exception + } driveScanner.removeListener('error', spy) driveScanner.stop() - done() + done(error) }) driveScanner.on('error', spy) @@ -371,10 +412,15 @@ describe('Browser: driveScanner', function () { it('should emit the error', function (done) { driveScanner.once('error', function (error) { - m.chai.expect(error).to.be.an.instanceof(Error) - m.chai.expect(error.message).to.equal('scan error') + let assertionError = null + try { + m.chai.expect(error).to.be.an.instanceof(Error) + m.chai.expect(error.message).to.equal('scan error') + } catch (exception) { + assertionError = exception + } driveScanner.stop() - done() + done(assertionError) }) driveScanner.start() diff --git a/tests/shared/drive-constraints.spec.js b/tests/shared/drive-constraints.spec.js index ad8ed348..39c6c386 100644 --- a/tests/shared/drive-constraints.spec.js +++ b/tests/shared/drive-constraints.spec.js @@ -23,29 +23,29 @@ const constraints = require('../../lib/shared/drive-constraints') describe('Shared: DriveConstraints', function () { describe('.isDriveLocked()', function () { - it('should return true if the drive is protected', function () { + it('should return true if the drive is read-only', function () { const result = constraints.isDriveLocked({ device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: true + isReadonly: true }) m.chai.expect(result).to.be.true }) - it('should return false if the drive is not protected', function () { + it('should return false if the drive is not read-only', function () { const result = constraints.isDriveLocked({ device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false }) m.chai.expect(result).to.be.false }) - it('should return false if we don\'t know if the drive is protected', function () { + it('should return false if we don\'t know if the drive is read-only', function () { const result = constraints.isDriveLocked({ device: '/dev/disk2', name: 'USB Drive', @@ -68,8 +68,8 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: true, - system: true + isReadonly: true, + isSystem: true }) m.chai.expect(result).to.be.true @@ -80,7 +80,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: true + isReadonly: true }) m.chai.expect(result).to.be.false @@ -91,8 +91,8 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: true, - system: false + isReadonly: true, + isSystem: false }) m.chai.expect(result).to.be.false @@ -111,8 +111,8 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: true, - system: false + isReadonly: true, + isSystem: false }, undefined) m.chai.expect(result).to.be.false @@ -131,8 +131,8 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: true, - system: false + isReadonly: true, + isSystem: false }, { path: '/Volumes/Untitled/image.img' }) @@ -313,7 +313,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 1000000000, - protected: false + isReadonly: false } }) @@ -515,7 +515,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 1000000000, - protected: false + isReadonly: false }, undefined) m.chai.expect(result).to.be.true @@ -533,7 +533,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 1000000000, - protected: false, + isReadonly: false, disabled: true }) @@ -545,7 +545,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 1000000000, - protected: false, + isReadonly: false, disabled: false }) @@ -557,7 +557,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 1000000000, - protected: false + isReadonly: false }) m.chai.expect(result).to.be.false @@ -570,7 +570,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 2000000001, - protected: false + isReadonly: false }, { path: path.join(__dirname, 'rpi.img'), size: { @@ -591,7 +591,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 2000000000, - protected: false + isReadonly: false }, { path: path.join(__dirname, 'rpi.img'), size: { @@ -612,7 +612,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 2000000000, - protected: false + isReadonly: false }, { path: path.join(__dirname, 'rpi.img'), size: { @@ -633,7 +633,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 2000000000, - protected: false + isReadonly: false }, { path: path.join(__dirname, 'rpi.img'), size: { @@ -669,7 +669,7 @@ describe('Shared: DriveConstraints', function () { device: '/dev/disk1', name: 'USB Drive', size: 2000000000, - protected: false + isReadonly: false }, undefined) m.chai.expect(result).to.be.true @@ -703,7 +703,7 @@ describe('Shared: DriveConstraints', function () { describe('given the drive is locked', function () { beforeEach(function () { - this.drive.protected = true + this.drive.isReadonly = true }) describe('given the drive is disabled', function () { @@ -825,7 +825,7 @@ describe('Shared: DriveConstraints', function () { describe('given the drive is not locked', function () { beforeEach(function () { - this.drive.protected = false + this.drive.isReadonly = false }) describe('given the drive is disabled', function () { @@ -959,8 +959,8 @@ describe('Shared: DriveConstraints', function () { this.drive = { device: '/dev/disk2', name: 'My Drive', - protected: false, - system: false, + isReadonly: false, + isSystem: false, disabled: false, mountpoints: [ { @@ -1026,7 +1026,7 @@ describe('Shared: DriveConstraints', function () { describe('given the drive is a system drive', () => { it('should return the system drive warning', function () { - this.drive.system = true + this.drive.isSystem = true const result = constraints.getDriveImageCompatibilityStatuses(this.drive, this.image) const expectedTuples = [ [ 'WARNING', 'SYSTEM' ] ] @@ -1060,7 +1060,7 @@ describe('Shared: DriveConstraints', function () { describe('given the drive is locked', () => { it('should return the locked drive error', function () { - this.drive.protected = true + this.drive.isReadonly = true const result = constraints.getDriveImageCompatibilityStatuses(this.drive, this.image) const expectedTuples = [ [ 'ERROR', 'LOCKED' ] ] @@ -1098,7 +1098,7 @@ describe('Shared: DriveConstraints', function () { describe('given a locked drive and image is null', () => { it('should return locked drive error', function () { - this.drive.protected = true + this.drive.isReadonly = true const result = constraints.getDriveImageCompatibilityStatuses(this.drive, null) const expectedTuples = [ [ 'ERROR', 'LOCKED' ] ] @@ -1109,7 +1109,7 @@ describe('Shared: DriveConstraints', function () { describe('given a system drive and image is null', () => { it('should return system drive warning', function () { - this.drive.system = true + this.drive.isSystem = true const result = constraints.getDriveImageCompatibilityStatuses(this.drive, null) const expectedTuples = [ [ 'WARNING', 'SYSTEM' ] ] @@ -1120,7 +1120,7 @@ describe('Shared: DriveConstraints', function () { describe('given the drive contains the image and the drive is locked', () => { it('should return the contains-image drive error by precedence', function () { - this.drive.protected = true + this.drive.isReadonly = true this.image.path = path.join(this.mountpoint, 'rpi.img') const result = constraints.getDriveImageCompatibilityStatuses(this.drive, this.image) @@ -1132,7 +1132,7 @@ describe('Shared: DriveConstraints', function () { describe('given a locked and too small drive', () => { it('should return the locked error by precedence', function () { - this.drive.protected = true + this.drive.isReadonly = true const result = constraints.getDriveImageCompatibilityStatuses(this.drive, this.image) const expectedTuples = [ [ 'ERROR', 'LOCKED' ] ] @@ -1144,7 +1144,7 @@ describe('Shared: DriveConstraints', function () { describe('given a too small and system drive', () => { it('should return the too small drive error by precedence', function () { this.image.size.final.value = this.drive.size + 1 - this.drive.system = true + this.drive.isSystem = true const result = constraints.getDriveImageCompatibilityStatuses(this.drive, this.image) const expectedTuples = [ [ 'ERROR', 'TOO_SMALL' ] ] @@ -1155,7 +1155,7 @@ describe('Shared: DriveConstraints', function () { describe('given a system drive and not recommended drive size', () => { it('should return both warnings', function () { - this.drive.system = true + this.drive.isSystem = true this.image.recommendedDriveSize = this.drive.size + 1 const result = constraints.getDriveImageCompatibilityStatuses(this.drive, this.image) diff --git a/tests/shared/models/available-drives.spec.js b/tests/shared/models/available-drives.spec.js index 27f2c17c..523c529d 100644 --- a/tests/shared/models/available-drives.spec.js +++ b/tests/shared/models/available-drives.spec.js @@ -65,8 +65,10 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', description: 'Foo', size: '14G', - mountpoint: '/mnt/foo', - system: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false } ] @@ -79,8 +81,10 @@ describe('Model: availableDrives', function () { constructor () { this.device = '/dev/sdb' this.description = 'Foo' - this.mountpoint = '/mnt/foo' - this.system = false + this.mountpoints = [ { + path: '/mnt/foo' + } ] + this.isSystem = false } } @@ -89,8 +93,10 @@ describe('Model: availableDrives', function () { { device: '/dev/sdb', description: 'Foo', - mountpoint: '/mnt/foo', - system: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false } ]) }) @@ -101,8 +107,10 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', description: 'Foo', size: '14G', - mountpoint: '/mnt/foo', - system: false, + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, foo: { bar: 'baz', qux: 5 @@ -121,8 +129,10 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', description: 'Foo', size: null, - mountpoint: '/mnt/foo', - system: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false } ] @@ -144,9 +154,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 999999999, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false } ]) @@ -190,17 +202,21 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 999999999, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false }, { device: '/dev/sdc', name: 'Bar', size: 999999999, - mountpoint: '/mnt/bar', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/bar' + } ], + isSystem: false, + isReadonly: false } ]) @@ -215,9 +231,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 2000000000, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false } ]) @@ -225,9 +243,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 2000000000, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false }) }) @@ -239,9 +259,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 99999999, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false } ]) @@ -256,9 +278,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 1500000000, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false } ]) @@ -273,9 +297,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 2000000000, - mountpoint: '/mnt/foo', - system: false, - protected: true + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: true } ]) @@ -295,8 +321,8 @@ describe('Model: availableDrives', function () { path: path.dirname(this.imagePath) } ], - system: false, - protected: false + isSystem: false, + isReadonly: false } ]) @@ -311,9 +337,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'Foo', size: 2000000000, - mountpoint: '/mnt/foo', - system: true, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: true, + isReadonly: false } ]) @@ -330,17 +358,21 @@ describe('Model: availableDrives', function () { device: '/dev/sdb', name: 'SD Card', size: 9999999, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false }, { device: '/dev/sdc', name: 'USB Drive', size: 9999999, - mountpoint: '/mnt/bar', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/bar' + } ], + isSystem: false, + isReadonly: false } ] @@ -354,9 +386,11 @@ describe('Model: availableDrives', function () { device: '/dev/sdc', name: 'USB Drive', size: 9999999, - mountpoint: '/mnt/bar', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/bar' + } ], + isSystem: false, + isReadonly: false } ]) @@ -378,17 +412,21 @@ describe('Model: availableDrives', function () { device: '/dev/sda', name: 'USB Drive', size: 9999999, - mountpoint: '/mnt/bar', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/bar' + } ], + isSystem: false, + isReadonly: false }, { device: '/dev/sdb', name: 'SD Card', size: 9999999, - mountpoint: '/mnt/foo', - system: false, - protected: false + mountpoints: [ { + path: '/mnt/foo' + } ], + isSystem: false, + isReadonly: false } ]) diff --git a/tests/shared/models/selection-state.spec.js b/tests/shared/models/selection-state.spec.js index cc71c249..e1e2ae3a 100644 --- a/tests/shared/models/selection-state.spec.js +++ b/tests/shared/models/selection-state.spec.js @@ -83,13 +83,13 @@ describe('Model: selectionState', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false }, { device: '/dev/disk5', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } ]) @@ -103,7 +103,7 @@ describe('Model: selectionState', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false }) }) }) @@ -123,7 +123,7 @@ describe('Model: selectionState', function () { device: '/dev/disk5', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false }) }) }) @@ -145,7 +145,7 @@ describe('Model: selectionState', function () { device: '/dev/disk5', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } ]) @@ -155,7 +155,7 @@ describe('Model: selectionState', function () { device: '/dev/disk5', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false }) }) @@ -165,7 +165,7 @@ describe('Model: selectionState', function () { device: '/dev/disk1', name: 'USB Drive', size: 999999999, - protected: true + isReadonly: true } ]) @@ -180,7 +180,7 @@ describe('Model: selectionState', function () { device: '/dev/disk1', name: 'USB Drive', size: 999999999, - protected: true + isReadonly: true } ]) @@ -226,7 +226,7 @@ describe('Model: selectionState', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999998, - protected: false + isReadonly: false } ]) @@ -756,7 +756,7 @@ describe('Model: selectionState', function () { device: '/dev/disk1', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } ]) @@ -785,7 +785,7 @@ describe('Model: selectionState', function () { device: '/dev/disk1', name: 'USB Drive', size: 1200000000, - protected: false + isReadonly: false } ]) @@ -828,7 +828,7 @@ describe('Model: selectionState', function () { path: path.dirname(imagePath) } ], - protected: false + isReadonly: false } ]) @@ -860,7 +860,7 @@ describe('Model: selectionState', function () { device: '/dev/disk1', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } ]) @@ -933,10 +933,12 @@ describe('Model: selectionState', function () { device: '/dev/sdb', description: 'DataTraveler 2.0', size: 999999999, - mountpoint: '/media/UNTITLED', + mountpoints: [ { + path: '/media/UNTITLED' + } ], name: '/dev/sdb', - system: false, - protected: false + isSystem: false, + isReadonly: false } ]) @@ -978,10 +980,12 @@ describe('Model: selectionState', function () { device: '/dev/sdb', description: 'DataTraveler 2.0', size: 999999999, - mountpoint: '/media/UNTITLED', + mountpoints: [ { + path: '/media/UNTITLED' + } ], name: '/dev/sdb', - system: false, - protected: false + isSystem: false, + isReadonly: false } availableDrives.setDrives([ @@ -990,7 +994,7 @@ describe('Model: selectionState', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } ]) @@ -1008,7 +1012,7 @@ describe('Model: selectionState', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } m.chai.expect(selectionState.getDrive()).to.deep.equal(this.drive) @@ -1028,7 +1032,7 @@ describe('Model: selectionState', function () { device: '/dev/disk2', name: 'USB Drive', size: 999999999, - protected: false + isReadonly: false } m.chai.expect(selectionState.hasDrive()).to.be.false