Skip to content

Commit 830f20f

Browse files
authored
fix: preserve allocation evaluation details when ASSIGNMENT_ERROR (#49)
ASSIGNMENT_ERROR later in the evaluation process should not revert the previously-done evaluation and definitely should not list unmatched/matched allocations as "unevaluated."
1 parent 4d3e92f commit 830f20f

File tree

2 files changed

+30
-34
lines changed

2 files changed

+30
-34
lines changed

test-validation/validate-tests.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ describe('UFC Test Validation', () => {
2424
describe.each(testCase.subjects.map(({subjectKey}) => subjectKey))('with subjectKey %s', (subjectKey) => {
2525
const subject = testCase.subjects.find((subject) => subject.subjectKey === subjectKey)!;
2626

27-
if (subject.evaluationDetails.variationValue === null) {
28-
it('should have `assignment` match `defaultValue` when `evaluationDetails.variationValue` is null', () => {
29-
expect(subject.assignment).toEqual(testCase.defaultValue);
30-
})
31-
}
32-
33-
if (subject.evaluationDetails.variationValue !== null) {
34-
it('should have `assignment` match `evaluationDetails.variationValue` when `evaluationDetails.variationValue` is not null', () => {
27+
if (subject.evaluationDetails.flagEvaluationCode === "MATCH") {
28+
it('should have `assignment` match `evaluationDetails.variationValue` when `evaluationDetails.flagEvaluationCode` is "MATCH"', () => {
3529
expect(subject.assignment).toEqual(subject.evaluationDetails.variationValue);
36-
})
30+
});
31+
} else {
32+
it('should have `assignment` match `defaultValue` when `evaluationDetails.flagEvaluationCode` is not "MATCH"', () => {
33+
expect(subject.assignment).toEqual(testCase.defaultValue);
34+
});
3735
}
3836
});
3937
})

ufc/tests/test-case-invalid-value-flag.json

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@
1616
"flagEvaluationDescription": "Variation (pi) is configured for type INTEGER, but is set to incompatible value (3.1415926)",
1717
"banditKey": null,
1818
"banditAction": null,
19-
"variationKey": null,
20-
"variationValue": null,
19+
"variationKey": "pi",
20+
"variationValue": 3.1415926,
2121
"matchedRule": null,
22-
"matchedAllocation": null,
23-
"unmatchedAllocations": [],
24-
"unevaluatedAllocations": [
22+
"matchedAllocation": {
23+
"key": "invalid",
24+
"allocationEvaluationCode": "MATCH",
25+
"orderPosition": 2
26+
},
27+
"unmatchedAllocations": [
2528
{
2629
"key": "valid",
27-
"allocationEvaluationCode": "UNEVALUATED",
30+
"allocationEvaluationCode": "FAILING_RULE",
2831
"orderPosition": 1
29-
},
30-
{
31-
"key": "invalid",
32-
"allocationEvaluationCode": "UNEVALUATED",
33-
"orderPosition": 2
3432
}
35-
]
33+
],
34+
"unevaluatedAllocations": []
3635
}
3736
},
3837
{
@@ -88,24 +87,23 @@
8887
"flagEvaluationDescription": "Variation (pi) is configured for type INTEGER, but is set to incompatible value (3.1415926)",
8988
"banditKey": null,
9089
"banditAction": null,
91-
"variationKey": null,
92-
"variationValue": null,
90+
"variationKey": "pi",
91+
"variationValue": 3.1415926,
9392
"matchedRule": null,
94-
"matchedAllocation": null,
95-
"unmatchedAllocations": [],
96-
"unevaluatedAllocations": [
93+
"matchedAllocation": {
94+
"key": "invalid",
95+
"allocationEvaluationCode": "MATCH",
96+
"orderPosition": 2
97+
},
98+
"unmatchedAllocations": [
9799
{
98100
"key": "valid",
99-
"allocationEvaluationCode": "UNEVALUATED",
101+
"allocationEvaluationCode": "FAILING_RULE",
100102
"orderPosition": 1
101-
},
102-
{
103-
"key": "invalid",
104-
"allocationEvaluationCode": "UNEVALUATED",
105-
"orderPosition": 2
106103
}
107-
]
104+
],
105+
"unevaluatedAllocations": []
108106
}
109107
}
110108
]
111-
}
109+
}

0 commit comments

Comments
 (0)