1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

[system_tracking] Make sure value array comparison is order insensitive

This commit is contained in:
Joe Fiorini 2015-07-01 16:18:00 -04:00
parent 0acf8aecbc
commit fef3d5d2b0
2 changed files with 46 additions and 3 deletions

View File

@ -100,11 +100,13 @@ export default
var slottedValues = slotFactValues(basisPosition, basisFactValues, comparatorFactValues); var slottedValues = slotFactValues(basisPosition, basisFactValues, comparatorFactValues);
if (!_.isEqual(slottedValues.left, slottedValues.right)) { var remaining = _.difference(slottedValues.left, slottedValues.right);
if (_.isEmpty(remaining)) {
slottedValues.isDivergent = false;
} else {
slottedValues.isDivergent = true; slottedValues.isDivergent = true;
containsValueArray = true; containsValueArray = true;
} else {
slottedValues.isDivergent = false;
} }
return slottedValues; return slottedValues;

View File

@ -504,6 +504,47 @@ describe('CompareFacts.Flat', function() {
expectation = expect(result).to.be.empty; expectation = expect(result).to.be.empty;
}); });
it('is insensitive to the order of the facts', function() {
var expectation;
var factTemplate =
{ hasTemplate:
function() {
return true;
},
render: function(fact) {
return fact.version;
}
};
var result = compareFacts(
{ position: 'left',
facts:
[{ 'name': 'some-package',
'version': 'efgh'
},
{ 'name': 'some-package',
'version': 'abcd'
}]
},
{ position: 'right',
facts:
[{ 'name': 'some-package',
'version': 'abcd'
},
{ 'name': 'some-package',
'version': 'efgh'
}]
}, options({ compareKey: ['value'],
factTemplate: factTemplate,
supportsValueArray: true
}));
// Use assignment to avoid jshint warning
expectation = expect(result).to.be.empty;
});
}); });
}); });