Investigate why tests fail when asserting against bucketing value of 100
fahad19 opened this issue · comments
Background
Tests can be run against defined features like this:
# tests/foo.feature.yml
feature: foo # your feature key
assertions:
# asserting evaluated variation
# against bucketed value and context
- description: Testing variation at 40% in NL
environment: production
at: 40
context:
country: nl
expectedToBeEnabled: true
Docs: https://featurevisor.com/docs/testing/
Issue
When at
value is set to 100
, it doesn't bucket as expected.
Investigate why that is the case.
Additional notes
I suspect the issue is same when asserting against the maximum range of the rule, irrespective of whether it is 100
or not.
- This area will be of high interest: https://github.com/featurevisor/featurevisor/blob/main/packages/sdk/src/feature.ts#L13-L15
Real world implications
Internally, the bucketing values are not as we see in our feature definitions and it tests.
- If percentage is
100
in our YAMLs, internally the value is100,000
- If percentage is
40
in our YAMLs, internally the value is40,000
This is for allowing percentage values to be expressed in 3 decimal places, if need be. So 49.999
percentage becomes a an integer of 49,999
internally.
The chances of the bucketed hashed value (between 0
and 100,000
to be exactly as the last value of the range is near zero. Therefore, no issues expected in real world applications.