Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
]
},
"devDependencies": {
"ajv": "^6.12.5",
"nock": "^13.0.4",
"sinon-chai": "^3.5.0"
},
Expand Down
84 changes: 84 additions & 0 deletions packages/build/src/download-center-schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const downloadCenterSchema = {
'type': 'object',
'required': [
'versions',
'manual_link',
'release_notes_link',
'previous_releases_link',
'development_releases_link',
'supported_browsers_link',
'tutorial_link'
],
'properties': {
'versions': {
'type': 'array',
'additionalItems': false,
'items': {
'type': 'object',
'required': [
'_id',
'version',
'platform'
],
'properties': {
'_id': {
'type': 'string'
},
'version': {
'type': 'string'
},
'platform': {
'type': 'array',
'additionalItems': false,
'items': {
'type': 'object',
'required': [
'arch',
'os',
'name',
'download_link'
],
'properties': {
'arch': {
'type': 'string'
},
'os': {
'type': 'string'
},
'name': {
'type': 'string'
},
'download_link': {
'type': 'string'
}
},
'additionalProperties': false
}
}
},
'additionalProperties': false
}
},
'manual_link': {
'type': 'string'
},
'release_notes_link': {
'type': 'string'
},
'previous_releases_link': {
'type': 'string'
},
'development_releases_link': {
'type': 'string'
},
'supported_browsers_link': {
'type': 'string'
},
'tutorial_link': {
'type': 'string'
}
},
'additionalProperties': false
};

export default downloadCenterSchema;
21 changes: 21 additions & 0 deletions packages/build/src/download-center.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { expect } from 'chai';
import nock from 'nock';

import Ajv from 'ajv';

import downloadCenterSchema from './download-center-schema';

import {
createDownloadCenterConfig,
verifyDownloadCenterConfig
} from './download-center';

function validateWithSchema(obj, schema): void {
const ajv = new Ajv();
const validate = ajv.compile(schema);
const valid = validate(obj);
if (!valid) {
throw new Error(ajv.errorsText(validate.errors));
}
}

describe('download center module', () => {
describe('.createDownloadCenterConfig', () => {
let config;
Expand All @@ -25,6 +38,14 @@ describe('download center module', () => {
it('returns the string with the win version injected', () => {
expect(config).to.include('mongosh-1.2.2-win32.zip');
});

it('produces a well formed json', () => {
expect(() => { JSON.parse(config); }).not.to.throw();
});

it('produces a json valid for the download center', () => {
validateWithSchema(JSON.parse(config), downloadCenterSchema);
});
});

describe('.verifyDownloadCenterConfig', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/download-center.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const CONFIG = `
"os": "debian",
"name": "Debian 64-bit",
"download_link": "https://downloads.mongodb.com/compass/mongosh_{{version}}_amd64.deb"
}
},
{
"arch": "x64",
"os": "rhel",
Expand Down