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:
parent
0acf8aecbc
commit
fef3d5d2b0
@ -100,11 +100,13 @@ export default
|
||||
|
||||
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;
|
||||
containsValueArray = true;
|
||||
} else {
|
||||
slottedValues.isDivergent = false;
|
||||
}
|
||||
|
||||
return slottedValues;
|
||||
|
@ -504,6 +504,47 @@ describe('CompareFacts.Flat', function() {
|
||||
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;
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user