Skip to content

Commit 25c57ee

Browse files
chrfwowtoddbaert
andauthored
feat: Add new test suite for context merging (#293)
## This PR Adds gherkin tests to verify the merging order of contexts: https://openfeature.dev/specification/sections/evaluation-context/#requirement-323 See open-feature/flagd-testbed#13 --------- Signed-off-by: christian.lutnik <[email protected]> Co-authored-by: Todd Baert <[email protected]>
1 parent 0cd553d commit 25c57ee

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
Feature: Context merging precedence
2+
3+
Background:
4+
Given a stable provider with retrievable context is registered
5+
6+
Scenario Outline: A context entry is added to a single level
7+
Given A context entry with key "key" and value "value" is added to the "<level>" level
8+
When Some flag was evaluated
9+
Then The merged context contains an entry with key "key" and value "value"
10+
11+
@transaction
12+
Examples:
13+
| level |
14+
| API |
15+
| Transaction |
16+
| Client |
17+
| Invocation |
18+
19+
@hooks
20+
Examples:
21+
| level |
22+
| API |
23+
| Client |
24+
| Invocation |
25+
| Before Hooks |
26+
27+
@hooks @transaction
28+
Examples:
29+
| level |
30+
| API |
31+
| Transaction |
32+
| Client |
33+
| Invocation |
34+
| Before Hooks |
35+
36+
@transaction
37+
Scenario: A context entry is added to each level with different keys
38+
Given A context entry with key "API" and value "API value" is added to the "API" level
39+
And A context entry with key "Transaction" and value "Transaction value" is added to the "Transaction" level
40+
And A context entry with key "Client" and value "Client value" is added to the "Client" level
41+
And A context entry with key "Invocation" and value "Invocation value" is added to the "Invocation" level
42+
When Some flag was evaluated
43+
Then The merged context contains an entry with key "API" and value "API value"
44+
And The merged context contains an entry with key "Transaction" and value "Transaction value"
45+
And The merged context contains an entry with key "Client" and value "Client value"
46+
And The merged context contains an entry with key "Invocation" and value "Invocation value"
47+
48+
@hooks
49+
Scenario: A context entry is added to each level with different keys
50+
Given A context entry with key "API" and value "API value" is added to the "API" level
51+
And A context entry with key "Client" and value "Client value" is added to the "Client" level
52+
And A context entry with key "Invocation" and value "Invocation value" is added to the "Invocation" level
53+
And A context entry with key "Before Hooks" and value "Before Hooks value" is added to the "Before Hooks" level
54+
When Some flag was evaluated
55+
Then The merged context contains an entry with key "API" and value "API value"
56+
And The merged context contains an entry with key "Client" and value "Client value"
57+
And The merged context contains an entry with key "Invocation" and value "Invocation value"
58+
And The merged context contains an entry with key "Before Hooks" and value "Before Hooks value"
59+
60+
@hooks @transaction
61+
Scenario: A context entry is added to each level with different keys
62+
Given A context entry with key "API" and value "API value" is added to the "API" level
63+
And A context entry with key "Transaction" and value "Transaction value" is added to the "Transaction" level
64+
And A context entry with key "Client" and value "Client value" is added to the "Client" level
65+
And A context entry with key "Invocation" and value "Invocation value" is added to the "Invocation" level
66+
And A context entry with key "Before Hooks" and value "Before Hooks value" is added to the "Before Hooks" level
67+
When Some flag was evaluated
68+
Then The merged context contains an entry with key "API" and value "API value"
69+
And The merged context contains an entry with key "Transaction" and value "Transaction value"
70+
And The merged context contains an entry with key "Client" and value "Client value"
71+
And The merged context contains an entry with key "Invocation" and value "Invocation value"
72+
And The merged context contains an entry with key "Before Hooks" and value "Before Hooks value"
73+
74+
@transaction
75+
Scenario Outline: A context entry in one level overwrites values with the same key from preceding levels
76+
Given A table with levels of increasing precedence
77+
| API |
78+
| Transaction |
79+
| Client |
80+
| Invocation |
81+
And Context entries for each level from API level down to the "<level>" level, with key "key" and value "<level>"
82+
When Some flag was evaluated
83+
Then The merged context contains an entry with key "key" and value "<level>"
84+
85+
Examples:
86+
| level |
87+
| API |
88+
| Transaction |
89+
| Client |
90+
| Invocation |
91+
92+
@hooks
93+
Scenario Outline: A context entry in one level overwrites values with the same key from preceding levels
94+
Given A table with levels of increasing precedence
95+
| API |
96+
| Client |
97+
| Invocation |
98+
| Before Hooks |
99+
And Context entries for each level from API level down to the "<level>" level, with key "key" and value "<level>"
100+
When Some flag was evaluated
101+
Then The merged context contains an entry with key "key" and value "<level>"
102+
103+
Examples:
104+
| level |
105+
| API |
106+
| Client |
107+
| Invocation |
108+
| Before Hooks |
109+
110+
@hooks @transaction
111+
Scenario Outline: A context entry in one level overwrites values with the same key from preceding levels
112+
Given A table with levels of increasing precedence
113+
| API |
114+
| Transaction |
115+
| Client |
116+
| Invocation |
117+
| Before Hooks |
118+
And Context entries for each level from API level down to the "<level>" level, with key "key" and value "<level>"
119+
When Some flag was evaluated
120+
Then The merged context contains an entry with key "key" and value "<level>"
121+
122+
Examples:
123+
| level |
124+
| API |
125+
| Transaction |
126+
| Client |
127+
| Invocation |
128+
| Before Hooks |

0 commit comments

Comments
 (0)