Skip to content

Commit 41c2021

Browse files
authored
feat: Add feature metadata tests (#31)
1 parent 6453b03 commit 41c2021

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
// Given: A feature with metadata, a segment overriding it and
3+
// including own feature metadata, and an identity matching the segment
4+
// When: A context is evaluated
5+
// Then: The result should include the feature metadata from the override
6+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
7+
"context": {
8+
"environment": {
9+
"key": "key",
10+
"name": "Environment"
11+
},
12+
"identity": {
13+
"identifier": "metadata_user",
14+
"key": "key_metadata_user"
15+
},
16+
"features": {
17+
"feature_with_metadata": {
18+
"enabled": true,
19+
"feature_key": "12345",
20+
"key": "1",
21+
"name": "feature_with_metadata",
22+
"value": null,
23+
"metadata": {
24+
"source": "imported"
25+
}
26+
}
27+
},
28+
"segments": {
29+
"1": {
30+
"key": "1",
31+
"name": "segment",
32+
"rules": [
33+
{
34+
"type": "ALL",
35+
"conditions": [
36+
{
37+
"operator": "EQUAL",
38+
"property": "$.identity.identifier",
39+
"value": "metadata_user"
40+
}
41+
]
42+
}
43+
],
44+
"overrides": [
45+
{
46+
"enabled": false,
47+
"feature_key": "12345",
48+
"feature": "feature_with_metadata",
49+
"key": "1",
50+
"name": "feature_with_metadata",
51+
"value": "overridden",
52+
"metadata": {
53+
"source": "overridden"
54+
}
55+
}
56+
]
57+
}
58+
}
59+
},
60+
"result": {
61+
"flags": {
62+
"feature_with_metadata": {
63+
"enabled": false,
64+
"feature_key": "12345",
65+
"name": "feature_with_metadata",
66+
"reason": "TARGETING_MATCH; segment=segment",
67+
"value": "overridden",
68+
"metadata": {
69+
"source": "overridden"
70+
}
71+
}
72+
},
73+
"segments": [
74+
{
75+
"key": "1",
76+
"name": "segment"
77+
}
78+
]
79+
}
80+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
// Given: A feature with metadata
3+
// When: A context is evaluated
4+
// Then: The result should include the feature metadata
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"features": {
12+
"feature_with_metadata": {
13+
"enabled": true,
14+
"feature_key": "12345",
15+
"key": "1",
16+
"name": "feature_with_metadata",
17+
"value": null,
18+
"metadata": {
19+
"source": "imported"
20+
}
21+
}
22+
}
23+
},
24+
"result": {
25+
"flags": {
26+
"feature_with_metadata": {
27+
"enabled": true,
28+
"feature_key": "12345",
29+
"name": "feature_with_metadata",
30+
"reason": "DEFAULT",
31+
"value": null,
32+
"metadata": {
33+
"source": "imported"
34+
}
35+
}
36+
},
37+
"segments": []
38+
}
39+
}

0 commit comments

Comments
 (0)