diff --git a/lib/gui/app/models/selection-state.js b/lib/gui/app/models/selection-state.js index db1196d0..180e209f 100644 --- a/lib/gui/app/models/selection-state.js +++ b/lib/gui/app/models/selection-state.js @@ -93,13 +93,9 @@ exports.deselectOtherDrives = (driveDevice) => { * @example * selectionState.selectImage({ * path: 'foo.img', - * size: { - * original: 1000000000, - * final: { - * estimation: false, - * value: 1000000000 - * } - * } + * size: 1000000000, + * compressedSize: 1000000000, + * isSizeEstimated: false, * }); */ exports.selectImage = (image) => { diff --git a/lib/gui/app/models/store.js b/lib/gui/app/models/store.js index 24d34f66..10e7d2d9 100644 --- a/lib/gui/app/models/store.js +++ b/lib/gui/app/models/store.js @@ -251,7 +251,7 @@ const storeReducer = (state = DEFAULT_STATE, action) => { }) } - if (action.data.percentage !== undefined) { + if (!_.isUndefined(action.data.percentage)) { if (!utils.isValidPercentage(action.data.percentage)) { throw errors.createError({ title: `Invalid state percentage: ${action.data.percentage}` @@ -426,10 +426,20 @@ const storeReducer = (state = DEFAULT_STATE, action) => { const MINIMUM_IMAGE_SIZE = 0 // eslint-disable-next-line no-undefined - if ((action.data.size !== undefined) && (action.data.size < MINIMUM_IMAGE_SIZE)) { - throw errors.createError({ - title: `Invalid image size: ${action.data.size}` - }) + if (action.data.size !== undefined) { + if ((action.data.size < MINIMUM_IMAGE_SIZE) || !_.isInteger(action.data.size)) { + throw errors.createError({ + title: `Invalid image size: ${action.data.size}` + }) + } + } + + if (!_.isUndefined(action.data.compressedSize)) { + if ((action.data.compressedSize < MINIMUM_IMAGE_SIZE) || !_.isInteger(action.data.compressedSize)) { + throw errors.createError({ + title: `Invalid image compressed size: ${action.data.compressedSize}` + }) + } } if (action.data.url && !_.isString(action.data.url)) { diff --git a/lib/gui/app/pages/main/controllers/flash.js b/lib/gui/app/pages/main/controllers/flash.js index 0fb1dfa2..0a98852c 100644 --- a/lib/gui/app/pages/main/controllers/flash.js +++ b/lib/gui/app/pages/main/controllers/flash.js @@ -110,13 +110,9 @@ module.exports = function ( * @example * FlashController.flashImageToDrive({ * path: 'rpi.img', - * size: { - * original: 1000000000, - * final: { - * estimation: false, - * value: 1000000000 - * } - * } + * size: 1000000000, + * compressedSize: 1000000000, + * isSizeEstimated: false, * }, [ * '/dev/disk2', * '/dev/disk5' diff --git a/lib/shared/drive-constraints.js b/lib/shared/drive-constraints.js index 21bfec08..07b58148 100644 --- a/lib/shared/drive-constraints.js +++ b/lib/shared/drive-constraints.js @@ -104,13 +104,9 @@ exports.isSystemDrive = (drive) => { * ] * }, { * path: '/Volumes/Untitled/image.img', - * size: { - * original: 1000000000, - * final: { - * estimation: false, - * value: 1000000000 - * } - * } + * size: 1000000000, + * compressedSize: 1000000000, + * isSizeEstimated: false, * })) { * console.log('This drive is a source drive!'); * } @@ -144,13 +140,9 @@ exports.isSourceDrive = (drive, image) => { * size: 1000000000 * }, { * path: 'rpi.img', - * size: { - * original: 1000000000, - * final: { - * estimation: false, - * value: 1000000000 - * } - * }, + * size: 1000000000, + * compressedSize: 1000000000, + * isSizeEstimated: false, * })) { * console.log('We can flash the image to this drive!'); * } @@ -158,12 +150,12 @@ exports.isSourceDrive = (drive, image) => { exports.isDriveLargeEnough = (drive, image) => { const driveSize = _.get(drive, [ 'size' ], UNKNOWN_SIZE) - if (_.get(image, [ 'size', 'final', 'estimation' ])) { + if (_.get(image, [ 'isSizeEstimated' ])) { // If the drive size is smaller than the original image size, and // the final image size is just an estimation, then we stop right // here, based on the assumption that the final size will never // be less than the original size. - if (driveSize < _.get(image, [ 'size', 'original' ], UNKNOWN_SIZE)) { + if (driveSize < _.get(image, [ 'compressedSize' ], UNKNOWN_SIZE)) { return false } @@ -174,11 +166,7 @@ exports.isDriveLargeEnough = (drive, image) => { return true } - return driveSize >= _.get(image, [ - 'size', - 'final', - 'value' - ], UNKNOWN_SIZE) + return driveSize >= _.get(image, [ 'size' ], UNKNOWN_SIZE) } /** @@ -220,13 +208,9 @@ exports.isDriveDisabled = (drive) => { * isReadOnly: false * }, { * path: 'rpi.img', - * size: { - * original: 1000000000, - * final: { - * estimation: false, - * value: 1000000000 - * } - * }, + * size: 1000000000, + * compressedSize: 1000000000, + * isSizeEstimated: false, * recommendedDriveSize: 2000000000 * })) { * console.log('This drive is valid!'); @@ -260,13 +244,9 @@ exports.isDriveValid = (drive, image) => { * * const image = { * path: 'rpi.img', - * size: { - * original: 2000000000, - * final: { - * estimation: false, - * value: 2000000000 - * } - * }, + * size: 2000000000, + * compressedSize: 2000000000, + * isSizeEstimated: false, * recommendedDriveSize: 4000000000 * }); * @@ -337,13 +317,9 @@ exports.COMPATIBILITY_STATUS_TYPES = { * * const image = { * path: '/path/to/rpi.img', - * size: { - * original: 2000000000, - * final: { - * estimation: false, - * value: 2000000000 - * } - * }, + * size: 2000000000, + * compressedSize: 2000000000, + * isSizeEstimated: false, * recommendedDriveSize: 4000000000 * }); * @@ -372,7 +348,7 @@ exports.getDriveImageCompatibilityStatuses = (drive, image) => { message: messages.compatibility.locked() }) } else if (!_.isNil(drive) && !_.isNil(drive.size) && !exports.isDriveLargeEnough(drive, image)) { - const imageSize = _.get(image, [ 'size', 'final', 'estimation' ]) ? image.size.original : image.size.final.value + const imageSize = _.get(image, [ 'isSizeEstimated' ]) ? image.size : image.compressedSize const relativeBytes = imageSize - drive.size statusList.push({ type: exports.COMPATIBILITY_STATUS_TYPES.ERROR, @@ -433,13 +409,9 @@ exports.getDriveImageCompatibilityStatuses = (drive, image) => { * * const image = { * path: '/path/to/rpi.img', - * size: { - * original: 2000000000, - * final: { - * estimation: false, - * value: 2000000000 - * } - * }, + * size: 2000000000, + * compressedSize: 2000000000, + * isSizeEstimated: false, * recommendedDriveSize: 4000000000 * }) * diff --git a/tests/gui/models/available-drives.spec.js b/tests/gui/models/available-drives.spec.js index 06f78bcb..5b6af4fc 100644 --- a/tests/gui/models/available-drives.spec.js +++ b/tests/gui/models/available-drives.spec.js @@ -154,13 +154,8 @@ describe('Model: availableDrives', function () { selectionState.selectImage({ path: this.imagePath, extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - }, + size: 999999999, + isSizeEstimated: false, recommendedDriveSize: 2000000000 }) }) diff --git a/tests/gui/models/flash-state.spec.js b/tests/gui/models/flash-state.spec.js index 2650e75d..db35c667 100644 --- a/tests/gui/models/flash-state.spec.js +++ b/tests/gui/models/flash-state.spec.js @@ -48,8 +48,8 @@ describe('Model: flashState', function () { successful: 0, failed: 0, percentage: 0, - speed: 0, - totalSpeed: 0 + speed: null, + totalSpeed: null }) }) @@ -352,8 +352,8 @@ describe('Model: flashState', function () { successful: 0, failed: 0, percentage: 0, - speed: 0, - totalSpeed: 0 + speed: null, + totalSpeed: null }) }) @@ -500,8 +500,8 @@ describe('Model: flashState', function () { successful: 0, failed: 0, percentage: 0, - speed: 0, - totalSpeed: 0 + speed: null, + totalSpeed: null }) }) diff --git a/tests/gui/models/selection-state.spec.js b/tests/gui/models/selection-state.spec.js index cf276589..d42c8f00 100644 --- a/tests/gui/models/selection-state.spec.js +++ b/tests/gui/models/selection-state.spec.js @@ -390,13 +390,7 @@ describe('Model: selectionState', function () { this.image = { path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - }, + size: 999999999, recommendedDriveSize: 1000000000, url: 'https://www.raspbian.org', supportUrl: 'https://www.raspbian.org/forums/', @@ -491,13 +485,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'bar.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) const imagePath = selectionState.getImagePath() @@ -527,13 +516,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) const imagePath = selectionState.getImagePath() @@ -547,13 +531,8 @@ describe('Model: selectionState', function () { path: 'foo.zip', extension: 'img', archiveExtension: 'zip', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) const imagePath = selectionState.getImagePath() @@ -565,13 +544,8 @@ describe('Model: selectionState', function () { path: 'foo.xz', extension: 'img', archiveExtension: 'xz', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) const imagePath = selectionState.getImagePath() @@ -583,13 +557,8 @@ describe('Model: selectionState', function () { path: 'something.linux-x86-64.gz', extension: 'img', archiveExtension: 'gz', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) const imagePath = selectionState.getImagePath() @@ -600,13 +569,8 @@ describe('Model: selectionState', function () { m.chai.expect(function () { selectionState.selectImage({ extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Missing image fields: path') }) @@ -616,13 +580,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 123, extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Invalid image path: 123') }) @@ -631,13 +590,8 @@ describe('Model: selectionState', function () { m.chai.expect(function () { selectionState.selectImage({ path: 'foo.img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Missing image fields: extension') }) @@ -647,13 +601,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 1, - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Invalid image extension: 1') }) @@ -663,13 +612,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'iso', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Missing image archive extension') }) @@ -680,15 +624,10 @@ describe('Model: selectionState', function () { path: 'foo.img', extension: 'iso', archiveExtension: 1, - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) - }).to.throw('Invalid image archive extension: 1') + }).to.throw('Missing image archive extension') }) it('should throw if the archive extension doesn\'t match the last path extension in a compressed image', function () { @@ -697,13 +636,8 @@ describe('Model: selectionState', function () { path: 'foo.img.xz', extension: 'img', archiveExtension: 'gz', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Image archive extension mismatch: gz and xz') }) @@ -713,13 +647,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.ifg', extension: 'ifg', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Invalid image extension: ifg') }) @@ -730,13 +659,8 @@ describe('Model: selectionState', function () { path: 'foo.ifg.gz', extension: 'ifg', archiveExtension: 'gz', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Invalid image extension: ifg') }) @@ -747,50 +671,22 @@ describe('Model: selectionState', function () { path: 'foo.img.ifg', extension: 'img', archiveExtension: 'ifg', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }).to.throw('Invalid image archive extension: ifg') }) - it('should throw if no size', function () { - m.chai.expect(function () { - selectionState.selectImage({ - path: 'foo.img', - extension: 'img' - }) - }).to.throw('Missing image fields: size') - }) - - it('should throw if size is not a plain object', function () { - m.chai.expect(function () { - selectionState.selectImage({ - path: 'foo.img', - extension: 'img', - size: 999999999 - }) - }).to.throw('Invalid image size: 999999999') - }) - it('should throw if the original size is not a number', function () { m.chai.expect(function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: '999999999', - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + compressedSize: '999999999', + isSizeEstimated: false }) - }).to.throw('Invalid original image size: 999999999') + }).to.throw('Invalid image compressed size: 999999999') }) it('should throw if the original size is a float number', function () { @@ -798,15 +694,11 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999.999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + compressedSize: 999999999.999, + isSizeEstimated: false }) - }).to.throw('Invalid original image size: 999999999.999') + }).to.throw('Invalid image compressed size: 999999999.999') }) it('should throw if the original size is negative', function () { @@ -814,15 +706,11 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: -1, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + compressedSize: -1, + isSizeEstimated: false }) - }).to.throw('Invalid original image size: -1') + }).to.throw('Invalid image compressed size: -1') }) it('should throw if the final size is not a number', function () { @@ -830,15 +718,10 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: '999999999' - } - } + size: '999999999', + isSizeEstimated: false }) - }).to.throw('Invalid final image size: 999999999') + }).to.throw('Invalid image size: 999999999') }) it('should throw if the final size is a float number', function () { @@ -846,15 +729,10 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999.999 - } - } + size: 999999999.999, + isSizeEstimated: false }) - }).to.throw('Invalid final image size: 999999999.999') + }).to.throw('Invalid image size: 999999999.999') }) it('should throw if the final size is negative', function () { @@ -862,31 +740,10 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: -1 - } - } + size: -1, + isSizeEstimated: false }) - }).to.throw('Invalid final image size: -1') - }) - - it('should throw if the final size estimation flag is not a boolean', function () { - m.chai.expect(function () { - selectionState.selectImage({ - path: 'foo.img', - extension: 'img', - size: { - original: 999999999, - final: { - estimation: 'false', - value: 999999999 - } - } - }) - }).to.throw('Invalid final image size estimation flag: false') + }).to.throw('Invalid image size: -1') }) it('should throw if url is defined but it\'s not a string', function () { @@ -894,13 +751,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - }, + size: 999999999, + isSizeEstimated: false, url: 1234 }) }).to.throw('Invalid image url: 1234') @@ -911,13 +763,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - }, + size: 999999999, + isSizeEstimated: false, name: 1234 }) }).to.throw('Invalid image name: 1234') @@ -928,13 +775,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - }, + size: 999999999, + isSizeEstimated: false, logo: 1234 }) }).to.throw('Invalid image logo: 1234') @@ -956,13 +798,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 1234567890, - final: { - estimation: false, - value: 1234567890 - } - } + size: 1234567890, + isSizeEstimated: false }) m.chai.expect(selectionState.hasDrive()).to.be.false @@ -985,13 +822,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - }, + size: 999999999, + isSizeEstimated: false, recommendedDriveSize: 1500000000 }) @@ -1028,13 +860,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: imagePath, extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) m.chai.expect(selectionState.hasDrive()).to.be.false @@ -1059,13 +886,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }) @@ -1177,13 +999,8 @@ describe('Model: selectionState', function () { selectionState.selectImage({ path: 'foo.img', extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) }) diff --git a/tests/gui/pages/main.spec.js b/tests/gui/pages/main.spec.js index 05e78305..adfec46d 100644 --- a/tests/gui/pages/main.spec.js +++ b/tests/gui/pages/main.spec.js @@ -70,13 +70,8 @@ describe('Browser: MainPage', function () { selectionState.selectImage({ path: 'rpi.img', extension: 'img', - size: { - original: 99999, - final: { - estimation: false, - value: 99999 - } - } + size: 99999, + isSizeEstimated: false }) m.chai.expect(controller.shouldDriveStepBeDisabled()).to.be.false @@ -103,13 +98,8 @@ describe('Browser: MainPage', function () { selectionState.selectImage({ path: 'rpi.img', extension: 'img', - size: { - original: 99999, - final: { - estimation: false, - value: 99999 - } - } + size: 99999, + isSizeEstimated: false }) m.chai.expect(controller.shouldFlashStepBeDisabled()).to.be.true @@ -157,13 +147,8 @@ describe('Browser: MainPage', function () { selectionState.selectImage({ path: 'rpi.img', extension: 'img', - size: { - original: 99999, - final: { - estimation: false, - value: 99999 - } - } + size: 99999, + isSizeEstimated: false }) m.chai.expect(controller.shouldFlashStepBeDisabled()).to.be.false @@ -197,13 +182,8 @@ describe('Browser: MainPage', function () { selectionState.selectImage({ path: path.join(__dirname, 'foo', 'bar.img'), extension: 'img', - size: { - original: 999999999, - final: { - estimation: false, - value: 999999999 - } - } + size: 999999999, + isSizeEstimated: false }) m.chai.expect(controller.getImageBasename()).to.equal('bar.img') diff --git a/tests/shared/drive-constraints.spec.js b/tests/shared/drive-constraints.spec.js index 87c4eb81..441be08f 100644 --- a/tests/shared/drive-constraints.spec.js +++ b/tests/shared/drive-constraints.spec.js @@ -323,13 +323,8 @@ describe('Shared: DriveConstraints', function () { beforeEach(function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size - 1, - final: { - estimation: false, - value: this.drive.size - 1 - } - } + size: this.drive.size - 1, + isSizeEstimated: false } }) @@ -352,13 +347,8 @@ describe('Shared: DriveConstraints', function () { beforeEach(function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size, - final: { - estimation: false, - value: this.drive.size - } - } + size: this.drive.size, + isSizeEstimated: false } }) @@ -381,13 +371,8 @@ describe('Shared: DriveConstraints', function () { beforeEach(function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size + 1, - final: { - estimation: false, - value: this.drive.size + 1 - } - } + size: this.drive.size + 1, + isSizeEstimated: false } }) @@ -412,13 +397,9 @@ describe('Shared: DriveConstraints', function () { beforeEach(function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size - 1, - final: { - estimation: true, - value: this.drive.size - 1 - } - } + size: this.drive.size - 1, + compressedSize: this.drive.size - 1, + isSizeEstimated: true } }) @@ -441,13 +422,9 @@ describe('Shared: DriveConstraints', function () { beforeEach(function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size, - final: { - estimation: true, - value: this.drive.size - } - } + size: this.drive.size, + compressedSize: this.drive.size, + isSizeEstimated: true } }) @@ -470,13 +447,9 @@ describe('Shared: DriveConstraints', function () { beforeEach(function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size + 1, - final: { - estimation: true, - value: this.drive.size + 1 - } - } + size: this.drive.size + 1, + compressedSize: this.drive.size + 1, + isSizeEstimated: true } }) @@ -499,13 +472,8 @@ describe('Shared: DriveConstraints', function () { it('should return false if the drive is undefined', function () { const result = constraints.isDriveLargeEnough(undefined, { path: path.join(__dirname, 'rpi.img'), - size: { - original: 1000000000, - final: { - estimation: false, - value: 1000000000 - } - } + size: 1000000000, + isSizeEstimated: false }) m.chai.expect(result).to.be.false @@ -574,13 +542,8 @@ describe('Shared: DriveConstraints', function () { isReadOnly: false }, { path: path.join(__dirname, 'rpi.img'), - size: { - original: 1000000000, - final: { - estimation: false, - value: 1000000000 - } - }, + size: 1000000000, + isSizeEstimated: false, recommendedDriveSize: 2000000000 }) @@ -595,13 +558,8 @@ describe('Shared: DriveConstraints', function () { isReadOnly: false }, { path: path.join(__dirname, 'rpi.img'), - size: { - original: 1000000000, - final: { - estimation: false, - value: 1000000000 - } - }, + size: 1000000000, + isSizeEstimated: false, recommendedDriveSize: 2000000000 }) @@ -616,13 +574,8 @@ describe('Shared: DriveConstraints', function () { isReadOnly: false }, { path: path.join(__dirname, 'rpi.img'), - size: { - original: 1000000000, - final: { - estimation: false, - value: 1000000000 - } - }, + size: 1000000000, + isSizeEstimated: false, recommendedDriveSize: 2000000001 }) @@ -637,13 +590,8 @@ describe('Shared: DriveConstraints', function () { isReadOnly: false }, { path: path.join(__dirname, 'rpi.img'), - size: { - original: 1000000000, - final: { - estimation: false, - value: 1000000000 - } - } + size: 1000000000, + isSizeEstimated: false }) m.chai.expect(result).to.be.true @@ -652,13 +600,8 @@ describe('Shared: DriveConstraints', function () { it('should return false if the drive is undefined', function () { const result = constraints.isDriveSizeRecommended(undefined, { path: path.join(__dirname, 'rpi.img'), - size: { - original: 1000000000, - final: { - estimation: false, - value: 1000000000 - } - }, + size: 1000000000, + isSizeEstimated: false, recommendedDriveSize: 1000000000 }) @@ -715,52 +658,32 @@ describe('Shared: DriveConstraints', function () { it('should return false if the drive is not large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is not large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) }) @@ -773,52 +696,32 @@ describe('Shared: DriveConstraints', function () { it('should return false if the drive is not large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is not large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) }) @@ -837,52 +740,32 @@ describe('Shared: DriveConstraints', function () { it('should return false if the drive is not large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is not large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) }) @@ -895,52 +778,32 @@ describe('Shared: DriveConstraints', function () { it('should return false if the drive is not large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is not large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 5000000000, - final: { - estimation: false, - value: 5000000000 - } - } + size: 5000000000, + isSizeEstimated: false })).to.be.false }) it('should return false if the drive is large enough and is a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.join(this.mountpoint, 'rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.false }) it('should return true if the drive is large enough and is not a source drive', function () { m.chai.expect(constraints.isDriveValid(this.drive, { path: path.resolve(this.mountpoint, '../bar/rpi.img'), - size: { - original: 2000000000, - final: { - estimation: false, - value: 2000000000 - } - } + size: 2000000000, + isSizeEstimated: false })).to.be.true }) }) @@ -965,13 +828,8 @@ describe('Shared: DriveConstraints', function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size - 1, - final: { - estimation: false, - value: this.drive.size - 1 - } - } + size: this.drive.size - 1, + isSizeEstimated: false } }) @@ -1015,13 +873,8 @@ describe('Shared: DriveConstraints', function () { this.image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: this.drive.size - 1, - final: { - estimation: false, - value: this.drive.size - 1 - } - } + size: this.drive.size - 1, + isSizeEstimated: false } }) @@ -1302,13 +1155,8 @@ describe('Shared: DriveConstraints', function () { const image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: drives[2].size + 1, - final: { - estimation: false, - value: drives[2].size + 1 - } - }, + size: drives[2].size + 1, + isSizeEstimated: false, recommendedDriveSize: drives[5].size + 1 } @@ -1478,13 +1326,8 @@ describe('Shared: DriveConstraints', function () { const image = { path: path.join(__dirname, 'rpi.img'), - size: { - original: drives[2].size + 1, - final: { - estimation: false, - value: drives[2].size + 1 - } - }, + size: drives[2].size + 1, + isSizeEstimated: false, recommendedDriveSize: drives[5].size + 1 }