Skip to content

Commit

Permalink
feat: enable "MD5_CHECK" by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Aug 17, 2022
1 parent 274499a commit 26cc408
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/api/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Default: `true`

Option `MD5_CHECK` is used to enable an md5 check after download

Default: `false`
Default: `true`

### ARCHIVE_NAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe('MongoBinaryDownload', () => {
expect(new MongoBinaryDownload({ checkMD5: false, downloadDir: '/' }).checkMD5).toBe(false);
});

it('if checkMD5 input parameter is missing, then it checks "MONGOMS_MD5_CHECK" environment variable', () => {
it('"checkMD5" should be disabled when config option is "false" and if config options is "true" it should be enabled', () => {
process.env[envName(ResolveConfigVariables.MD5_CHECK)] = '0';
expect(new MongoBinaryDownload({ downloadDir: '/' }).checkMD5).toBe(false);
process.env[envName(ResolveConfigVariables.MD5_CHECK)] = '1';
expect(new MongoBinaryDownload({ downloadDir: '/' }).checkMD5).toBe(true);
Expand Down Expand Up @@ -258,8 +259,8 @@ describe('MongoBinaryDownload', () => {
jest.spyOn(MongoBinaryDownloadUrl.prototype, 'getDownloadUrl').mockResolvedValue(downloadUrl);

const du = new MongoBinaryDownload({ downloadDir: '/' });
jest.spyOn(du, 'download').mockResolvedValue(archivePath);
jest.spyOn(du, 'makeMD5check');
jest.spyOn(du, 'download').mockResolvedValue(archivePath); // mocking to not actually download a binary
jest.spyOn(du, 'makeMD5check').mockResolvedValue(true); // mocking because archive path does not exist to be tested

const returnValue = await du.startDownload();
expect(returnValue).toEqual(archivePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const defaultValues = new Map<ResolveConfigVariables, string>([
[ResolveConfigVariables.USE_HTTP, 'false'],
[ResolveConfigVariables.SYSTEM_BINARY_VERSION_CHECK, 'true'],
[ResolveConfigVariables.USE_ARCHIVE_NAME_FOR_BINARY_NAME, 'false'],
[ResolveConfigVariables.MD5_CHECK, 'true'],
]);

/** Interface for storing information about the found package.json from `findPackageJson` */
Expand Down

0 comments on commit 26cc408

Please sign in to comment.