Skip to content

Commit

Permalink
fix: preserve allocation evaluation details when ASSIGNMENT_ERROR (#49)
Browse files Browse the repository at this point in the history
ASSIGNMENT_ERROR later in the evaluation process should not revert the
previously-done evaluation and definitely should not list
unmatched/matched allocations as "unevaluated."
  • Loading branch information
rasendubi authored Jul 31, 2024
1 parent 4d3e92f commit 830f20f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
16 changes: 7 additions & 9 deletions test-validation/validate-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ describe('UFC Test Validation', () => {
describe.each(testCase.subjects.map(({subjectKey}) => subjectKey))('with subjectKey %s', (subjectKey) => {
const subject = testCase.subjects.find((subject) => subject.subjectKey === subjectKey)!;

if (subject.evaluationDetails.variationValue === null) {
it('should have `assignment` match `defaultValue` when `evaluationDetails.variationValue` is null', () => {
expect(subject.assignment).toEqual(testCase.defaultValue);
})
}

if (subject.evaluationDetails.variationValue !== null) {
it('should have `assignment` match `evaluationDetails.variationValue` when `evaluationDetails.variationValue` is not null', () => {
if (subject.evaluationDetails.flagEvaluationCode === "MATCH") {
it('should have `assignment` match `evaluationDetails.variationValue` when `evaluationDetails.flagEvaluationCode` is "MATCH"', () => {
expect(subject.assignment).toEqual(subject.evaluationDetails.variationValue);
})
});
} else {
it('should have `assignment` match `defaultValue` when `evaluationDetails.flagEvaluationCode` is not "MATCH"', () => {
expect(subject.assignment).toEqual(testCase.defaultValue);
});
}
});
})
Expand Down
48 changes: 23 additions & 25 deletions ufc/tests/test-case-invalid-value-flag.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@
"flagEvaluationDescription": "Variation (pi) is configured for type INTEGER, but is set to incompatible value (3.1415926)",
"banditKey": null,
"banditAction": null,
"variationKey": null,
"variationValue": null,
"variationKey": "pi",
"variationValue": 3.1415926,
"matchedRule": null,
"matchedAllocation": null,
"unmatchedAllocations": [],
"unevaluatedAllocations": [
"matchedAllocation": {
"key": "invalid",
"allocationEvaluationCode": "MATCH",
"orderPosition": 2
},
"unmatchedAllocations": [
{
"key": "valid",
"allocationEvaluationCode": "UNEVALUATED",
"allocationEvaluationCode": "FAILING_RULE",
"orderPosition": 1
},
{
"key": "invalid",
"allocationEvaluationCode": "UNEVALUATED",
"orderPosition": 2
}
]
],
"unevaluatedAllocations": []
}
},
{
Expand Down Expand Up @@ -88,24 +87,23 @@
"flagEvaluationDescription": "Variation (pi) is configured for type INTEGER, but is set to incompatible value (3.1415926)",
"banditKey": null,
"banditAction": null,
"variationKey": null,
"variationValue": null,
"variationKey": "pi",
"variationValue": 3.1415926,
"matchedRule": null,
"matchedAllocation": null,
"unmatchedAllocations": [],
"unevaluatedAllocations": [
"matchedAllocation": {
"key": "invalid",
"allocationEvaluationCode": "MATCH",
"orderPosition": 2
},
"unmatchedAllocations": [
{
"key": "valid",
"allocationEvaluationCode": "UNEVALUATED",
"allocationEvaluationCode": "FAILING_RULE",
"orderPosition": 1
},
{
"key": "invalid",
"allocationEvaluationCode": "UNEVALUATED",
"orderPosition": 2
}
]
],
"unevaluatedAllocations": []
}
}
]
}
}

0 comments on commit 830f20f

Please sign in to comment.