Skip to content

Commit

Permalink
test(image-stream): Fix test image data (#1535)
Browse files Browse the repository at this point in the history
This updates the base test image to be a complete, but small
disk image, as thre previous image was quite large for running tests (32MB),
and was chopped off at an arbitrary position, causing other tools to fail
on it as an input.

Change-Type: patch
  • Loading branch information
jhermsmeier authored Jun 21, 2017
1 parent dbc8aa1 commit 4f4c606
Show file tree
Hide file tree
Showing 38 changed files with 60 additions and 62 deletions.
6 changes: 3 additions & 3 deletions tests/image-stream/bz2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ describe('ImageStream: BZ2', function() {

describe('given a bz2 image', function() {
tester.extractFromFilePath(
path.join(BZ2_PATH, 'raspberrypi.img.bz2'),
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(BZ2_PATH, 'etcher-test.img.bz2'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(BZ2_PATH, 'raspberrypi.img.bz2');
const image = path.join(BZ2_PATH, 'etcher-test.img.bz2');
const expectedSize = fs.statSync(image).size;

return imageStream.getImageMetadata(image).then((metadata) => {
Expand Down
Binary file added tests/image-stream/data/bz2/etcher-test.img.bz2
Binary file not shown.
Binary file removed tests/image-stream/data/bz2/raspberrypi.img.bz2
Binary file not shown.
Binary file added tests/image-stream/data/dmg/etcher-test-raw.dmg
Binary file not shown.
Binary file added tests/image-stream/data/dmg/etcher-test-zlib.dmg
Binary file not shown.
Binary file removed tests/image-stream/data/dmg/raw.dmg
Binary file not shown.
Binary file removed tests/image-stream/data/dmg/zlib-compressed.dmg
Binary file not shown.
Binary file added tests/image-stream/data/gz/etcher-test.img.gz
Binary file not shown.
Binary file removed tests/image-stream/data/gz/raspberrypi.img.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed tests/image-stream/data/images/raspberrypi.img
Binary file not shown.
Binary file removed tests/image-stream/data/images/raspberrypi.iso
Binary file not shown.
Binary file removed tests/image-stream/data/images/raw.img
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/image-stream/data/xz/etcher-test.img.xz
Binary file not shown.
Binary file removed tests/image-stream/data/xz/raspberrypi.img.xz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 9 additions & 9 deletions tests/image-stream/dmg.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ describe('ImageStream: DMG', function() {

this.timeout(20000);

context('compressed', function() {
context('zlib compressed', function() {

describe('.getFromFilePath()', function() {

describe('given an dmg image', function() {
tester.extractFromFilePath(
path.join(DMG_PATH, 'zlib-compressed.dmg'),
path.join(IMAGES_PATH, 'zlib-compressed.img'));
path.join(DMG_PATH, 'etcher-test-zlib.dmg'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(DMG_PATH, 'zlib-compressed.dmg');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'zlib-compressed.img')).size;
const image = path.join(DMG_PATH, 'etcher-test-zlib.dmg');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
const compressedSize = fs.statSync(image).size;

return imageStream.getImageMetadata(image).then((metadata) => {
Expand Down Expand Up @@ -73,17 +73,17 @@ describe('ImageStream: DMG', function() {

describe('given an dmg image', function() {
tester.extractFromFilePath(
path.join(DMG_PATH, 'raw.dmg'),
path.join(IMAGES_PATH, 'raw.img'));
path.join(DMG_PATH, 'etcher-test-raw.dmg'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(DMG_PATH, 'raw.dmg');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'raw.img')).size;
const image = path.join(DMG_PATH, 'etcher-test-raw.dmg');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
const compressedSize = fs.statSync(image).size;

return imageStream.getImageMetadata(image).then((metadata) => {
Expand Down
10 changes: 5 additions & 5 deletions tests/image-stream/gz.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ describe('ImageStream: GZ', function() {

describe('given a gz image', function() {
tester.extractFromFilePath(
path.join(GZ_PATH, 'raspberrypi.img.gz'),
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(GZ_PATH, 'etcher-test.img.gz'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(GZ_PATH, 'raspberrypi.img.gz');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'raspberrypi.img')).size;
const compressedSize = fs.statSync(path.join(GZ_PATH, 'raspberrypi.img.gz')).size;
const image = path.join(GZ_PATH, 'etcher-test.img.gz');
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;
const compressedSize = fs.statSync(path.join(GZ_PATH, 'etcher-test.img.gz')).size;

return imageStream.getImageMetadata(image).then((metadata) => {
m.chai.expect(metadata).to.deep.equal({
Expand Down
6 changes: 3 additions & 3 deletions tests/image-stream/img.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ describe('ImageStream: IMG', function() {

describe('given an img image', function() {
tester.extractFromFilePath(
path.join(IMAGES_PATH, 'raspberrypi.img'),
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(IMAGES_PATH, 'etcher-test.img'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(IMAGES_PATH, 'raspberrypi.img');
const image = path.join(IMAGES_PATH, 'etcher-test.img');
const expectedSize = fs.statSync(image).size;

return imageStream.getImageMetadata(image).then((metadata) => {
Expand Down
6 changes: 3 additions & 3 deletions tests/image-stream/iso.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ describe('ImageStream: ISO', function() {

describe('given an iso image', function() {
tester.extractFromFilePath(
path.join(IMAGES_PATH, 'raspberrypi.iso'),
path.join(IMAGES_PATH, 'raspberrypi.iso'));
path.join(IMAGES_PATH, 'etcher-test.iso'),
path.join(IMAGES_PATH, 'etcher-test.iso'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(IMAGES_PATH, 'raspberrypi.iso');
const image = path.join(IMAGES_PATH, 'etcher-test.iso');
const expectedSize = fs.statSync(image).size;

return imageStream.getImageMetadata(image).then((metadata) => {
Expand Down
40 changes: 19 additions & 21 deletions tests/image-stream/metadata/zip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ describe('ImageStream: Metadata ZIP', function() {
describe('given an archive with an invalid `manifest.json`', function() {

tester.expectError(
path.join(ZIP_PATH, 'rpi-invalid-manifest.zip'),
path.join(ZIP_PATH, 'etcher-test-invalid-manifest.zip'),
'Invalid archive manifest.json');

describe('.getImageMetadata()', function() {

it('should be rejected with an error', function(done) {
const image = path.join(ZIP_PATH, 'rpi-invalid-manifest.zip');
it('should be rejected with an error', function() {
const image = path.join(ZIP_PATH, 'etcher-test-invalid-manifest.zip');

imageStream.getImageMetadata(image).catch((error) => {
return imageStream.getImageMetadata(image).catch((error) => {
m.chai.expect(error).to.be.an.instanceof(Error);
m.chai.expect(error.message).to.equal('Invalid archive manifest.json');
done();
});
});

Expand All @@ -62,31 +61,31 @@ describe('ImageStream: Metadata ZIP', function() {

describe('given an archive with a `manifest.json`', function() {

const archive = path.join(ZIP_PATH, 'rpi-with-manifest.zip');
const archive = path.join(ZIP_PATH, 'etcher-test-with-manifest.zip');

tester.extractFromFilePath(
archive,
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(IMAGES_PATH, 'etcher-test.img'));

it('should read the manifest name property', function() {
return testMetadataProperty(archive, 'name', 'Raspberry Pi');
return testMetadataProperty(archive, 'name', 'Etcher Test');
});

it('should read the manifest version property', function() {
return testMetadataProperty(archive, 'version', '1.0.0');
});

it('should read the manifest url property', function() {
return testMetadataProperty(archive, 'url', 'https://www.raspberrypi.org');
return testMetadataProperty(archive, 'url', 'https://www.example.com');
});

it('should read the manifest supportUrl property', function() {
const expectedValue = 'https://www.raspberrypi.org/forums/';
const expectedValue = 'https://www.example.com/support/';
return testMetadataProperty(archive, 'supportUrl', expectedValue);
});

it('should read the manifest releaseNotesUrl property', function() {
const expectedValue = 'http://downloads.raspberrypi.org/raspbian/release_notes.txt';
const expectedValue = 'http://downloads.example.com/release_notes.txt';
return testMetadataProperty(archive, 'releaseNotesUrl', expectedValue);
});

Expand All @@ -110,7 +109,7 @@ describe('ImageStream: Metadata ZIP', function() {

describe('given an archive with a `logo.svg`', function() {

const archive = path.join(ZIP_PATH, 'rpi-with-logo.zip');
const archive = path.join(ZIP_PATH, 'etcher-test-with-logo.zip');

const logo = [
'<svg xmlns="http://www.w3.org/2000/svg">',
Expand All @@ -127,19 +126,18 @@ describe('ImageStream: Metadata ZIP', function() {

describe('given an archive with a bmap file', function() {

const archive = path.join(ZIP_PATH, 'rpi-with-bmap.zip');
const archive = path.join(ZIP_PATH, 'etcher-test-with-bmap.zip');

const bmap = [
'<?xml version="1.0" ?>',
'<bmap version="1.3">',
' <ImageSize> 36864 </ImageSize>',
' <ImageSize> 5242880 </ImageSize>',
' <BlockSize> 4096 </BlockSize>',
' <BlocksCount> 9 </BlocksCount>',
' <MappedBlocksCount> 4 </MappedBlocksCount>',
' <BmapFileSHA1> d90f372215cbbef8801caca7b1dd7e587b2142cc </BmapFileSHA1>',
' <BlocksCount> 1280 </BlocksCount>',
' <MappedBlocksCount> 1280 </MappedBlocksCount>',
' <BmapFileSHA1> cc6f077565c73a46198777b259c231875df4e709 </BmapFileSHA1>',
' <BlockMap>',
' <Range sha1="193edb53bde599f58369f4e83a6c5d54b96819ce"> 0-1 </Range>',
' <Range sha1="193edb53bde599f58369f4e83a6c5d54b96819ce"> 7-8 </Range>',
' <Range sha1="7b7d6e1fc44ef224a8c57d3ec6ffc3717c428a14"> 0-1280 </Range>',
' </BlockMap>',
'</bmap>',
''
Expand All @@ -153,10 +151,10 @@ describe('ImageStream: Metadata ZIP', function() {

describe('given an archive with instructions', function() {

const archive = path.join(ZIP_PATH, 'rpi-with-instructions.zip');
const archive = path.join(ZIP_PATH, 'etcher-test-with-instructions.zip');

const instructions = [
'# Raspberry Pi Next Steps',
'# Example Next Steps',
'',
'Lorem ipsum dolor sit amet.',
''
Expand Down
16 changes: 8 additions & 8 deletions tests/image-stream/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,56 @@ describe('ImageStream: Utils', function() {
describe('.getArchiveMimeType()', function() {

it('should resolve application/x-bzip2 for a bz2 archive', function() {
const file = path.join(DATA_PATH, 'bz2', 'raspberrypi.img.bz2');
const file = path.join(DATA_PATH, 'bz2', 'etcher-test.img.bz2');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/x-bzip2');
});
});

it('should resolve application/x-xz for a xz archive', function() {
const file = path.join(DATA_PATH, 'xz', 'raspberrypi.img.xz');
const file = path.join(DATA_PATH, 'xz', 'etcher-test.img.xz');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/x-xz');
});
});

it('should resolve application/gzip for a gz archive', function() {
const file = path.join(DATA_PATH, 'gz', 'raspberrypi.img.gz');
const file = path.join(DATA_PATH, 'gz', 'etcher-test.img.gz');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/gzip');
});
});

it('should resolve application/zip for a zip archive', function() {
const file = path.join(DATA_PATH, 'zip', 'zip-directory-rpi-only.zip');
const file = path.join(DATA_PATH, 'zip', 'zip-directory-etcher-only.zip');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/zip');
});
});

it('should resolve application/octet-stream for an uncompressed image', function() {
const file = path.join(DATA_PATH, 'images', 'raspberrypi.img');
const file = path.join(DATA_PATH, 'images', 'etcher-test.img');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/octet-stream');
});
});

it('should resolve application/x-iso9660-image for an uncompressed iso', function() {
const file = path.join(DATA_PATH, 'images', 'raspberrypi.iso');
const file = path.join(DATA_PATH, 'images', 'etcher-test.iso');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/x-iso9660-image');
});
});

it('should resolve application/x-apple-diskimage for a compressed Apple disk image', function() {
const file = path.join(DATA_PATH, 'dmg', 'zlib-compressed.dmg');
const file = path.join(DATA_PATH, 'dmg', 'etcher-test-zlib.dmg');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/x-apple-diskimage');
});
});

it('should resolve application/x-apple-diskimage for an uncompressed Apple disk image', function() {
const file = path.join(DATA_PATH, 'dmg', 'raw.dmg');
const file = path.join(DATA_PATH, 'dmg', 'etcher-test-raw.dmg');
return utils.getArchiveMimeType(file).then((type) => {
m.chai.expect(type).to.equal('application/x-apple-diskimage');
});
Expand Down
8 changes: 4 additions & 4 deletions tests/image-stream/xz.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ describe('ImageStream: XZ', function() {

describe('given a xz image', function() {
tester.extractFromFilePath(
path.join(XZ_PATH, 'raspberrypi.img.xz'),
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(XZ_PATH, 'etcher-test.img.xz'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(XZ_PATH, 'raspberrypi.img.xz');
const image = path.join(XZ_PATH, 'etcher-test.img.xz');
const compressedSize = fs.statSync(image).size;
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'raspberrypi.img')).size;
const uncompressedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;

return imageStream.getImageMetadata(image).then((metadata) => {
m.chai.expect(metadata).to.deep.equal({
Expand Down
12 changes: 6 additions & 6 deletions tests/image-stream/zip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@ describe('ImageStream: ZIP', function() {

describe('given a zip directory containing only an image', function() {
tester.extractFromFilePath(
path.join(ZIP_PATH, 'zip-directory-rpi-only.zip'),
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(ZIP_PATH, 'zip-directory-etcher-test-only.zip'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

describe('given a zip directory containing an image and other misc files', function() {
tester.extractFromFilePath(
path.join(ZIP_PATH, 'zip-directory-rpi-and-misc.zip'),
path.join(IMAGES_PATH, 'raspberrypi.img'));
path.join(ZIP_PATH, 'zip-directory-etcher-test-and-misc.zip'),
path.join(IMAGES_PATH, 'etcher-test.img'));
});

});

describe('.getImageMetadata()', function() {

it('should return the correct metadata', function() {
const image = path.join(ZIP_PATH, 'zip-directory-rpi-only.zip');
const expectedSize = fs.statSync(path.join(IMAGES_PATH, 'raspberrypi.img')).size;
const image = path.join(ZIP_PATH, 'zip-directory-etcher-test-only.zip');
const expectedSize = fs.statSync(path.join(IMAGES_PATH, 'etcher-test.img')).size;

return imageStream.getImageMetadata(image).then((metadata) => {
m.chai.expect(metadata).to.deep.equal({
Expand Down

0 comments on commit 4f4c606

Please sign in to comment.