Skip to content

Instrument package data #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 8, 2021
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
41 changes: 24 additions & 17 deletions bin/helpers/checkUploaded.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,7 @@ const checkSpecsMd5 = (runSettings, excludeFiles) => {
hashHelper.hashWrapper(options).then(function (data) {
const outputHash = crypto.createHash(Constants.hashingOptions.algo);
outputHash.update(data);
let packageJSON = {};

if (typeof runSettings.package_config_options === 'object') {
Object.assign(packageJSON, runSettings.package_config_options);
}

if (typeof runSettings.npm_dependencies === 'object') {
Object.assign(packageJSON, {
devDependencies: runSettings.npm_dependencies,
});
}

if (Object.keys(packageJSON).length > 0) {
let packageJSONString = JSON.stringify(packageJSON);
outputHash.update(packageJSONString);
}
outputHash.update(checkPackageMd5(runSettings));

if (
runSettings.cypress_config_file &&
Expand All @@ -56,6 +41,27 @@ const checkSpecsMd5 = (runSettings, excludeFiles) => {
});
};

const checkPackageMd5 = (runSettings) => {
const outputHash = crypto.createHash(Constants.hashingOptions.algo);
let packageJSON = {};
if (typeof runSettings.package_config_options === 'object') {
Object.assign(packageJSON, runSettings.package_config_options);
}

if (typeof runSettings.npm_dependencies === 'object') {
Object.assign(packageJSON, {
devDependencies: runSettings.npm_dependencies,
});
}

if (Object.keys(packageJSON).length > 0) {
let packageJSONString = JSON.stringify(packageJSON);
outputHash.update(packageJSONString);
}

return outputHash.digest(Constants.hashingOptions.encoding)
};

const checkUploadedMd5 = (bsConfig, args) => {
return new Promise(function (resolve) {
let obj = {
Expand All @@ -66,7 +72,8 @@ const checkUploadedMd5 = (bsConfig, args) => {
}
checkSpecsMd5(bsConfig.run_settings, args.exclude).then(function (md5data) {
Object.assign(obj, {md5sum: md5data});
let data = JSON.stringify({ zip_md5sum: md5data });
let package_md5sum = checkPackageMd5(bsConfig.run_settings);
let data = JSON.stringify({ zip_md5sum: md5data, instrument_package_md5sum: package_md5sum});

let options = {
url: config.checkMd5sum,
Expand Down
8 changes: 4 additions & 4 deletions test/unit/bin/helpers/checkUploaded.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ describe("checkUploaded", () => {
.then(function (data) {
chai.assert.equal(data, 'random_md5sum')
sinon.assert.calledOnce(hashElementstub);
sinon.assert.calledOnce(digestStub);
sinon.assert.calledOnce(updateStub);
sinon.assert.calledTwice(digestStub);
sinon.assert.calledTwice(updateStub);
})
.catch((error) => {
chai.assert.fail("Promise error");
Expand All @@ -188,8 +188,8 @@ describe("checkUploaded", () => {
.then(function (data) {
chai.assert.equal(data, 'random_md5sum')
sinon.assert.calledOnce(hashElementstub);
sinon.assert.calledOnce(digestStub);
sinon.assert.calledThrice(updateStub);
sinon.assert.called(digestStub);
sinon.assert.callCount(updateStub, 4);
})
.catch((error) => {
chai.assert.fail("Promise error");
Expand Down