Skip to content

Commit 6ab57ec

Browse files
authored
feat: Add tests for implicit identity key (#34)
1 parent 8d19e96 commit 6ab57ec

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
// Given: A multivariate feature with one variant and an identity key resulting in %54.53 allocation
3+
// When: Evaluating the feature for the given identity
4+
// Then: The variant should be selected as the feature value
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "test_env",
9+
"name": "Test Environment"
10+
},
11+
"identity": {
12+
"identifier": "foobar",
13+
"key": "test_env_foobar"
14+
},
15+
"features": {
16+
"multivariate_feature": {
17+
"enabled": true,
18+
"key": "78986",
19+
"name": "multivariate_feature",
20+
"value": "foo",
21+
"variants": [
22+
{
23+
"value": "variant_value",
24+
"weight": 54.54,
25+
"priority": 1
26+
}
27+
]
28+
}
29+
},
30+
"segments": {}
31+
},
32+
"result": {
33+
"flags": {
34+
"multivariate_feature": {
35+
"enabled": true,
36+
"name": "multivariate_feature",
37+
"reason": "SPLIT; weight=54.54",
38+
"value": "variant_value"
39+
}
40+
},
41+
"segments": []
42+
}
43+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
// Given: A multivariate feature with one variant and an identity identifier
3+
// expected to produce an identity key resulting in %54.53 allocation
4+
// When: Evaluating the feature for the given identity
5+
// Then: The variant should be selected as the feature value.
6+
//
7+
// NOTE: The expectation is that the engine constructs the identity key internally
8+
// using the environment key and identity identifier. In this case, we expect
9+
// the constructed key to be "test_env_foobar" which results in 54.53% allocation.
10+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
11+
"context": {
12+
"environment": {
13+
"key": "test_env",
14+
"name": "Test Environment"
15+
},
16+
"identity": {
17+
"identifier": "foobar"
18+
},
19+
"features": {
20+
"multivariate_feature": {
21+
"enabled": true,
22+
"key": "78986",
23+
"name": "multivariate_feature",
24+
"value": "foo",
25+
"variants": [
26+
{
27+
"value": "variant_value",
28+
"weight": 54.54,
29+
"priority": 1
30+
}
31+
]
32+
}
33+
},
34+
"segments": {}
35+
},
36+
"result": {
37+
"flags": {
38+
"multivariate_feature": {
39+
"enabled": true,
40+
"name": "multivariate_feature",
41+
"reason": "SPLIT; weight=54.54",
42+
"value": "variant_value"
43+
}
44+
},
45+
"segments": []
46+
}
47+
}

0 commit comments

Comments
 (0)