Skip to content

Commit e13251e

Browse files
feat: add disabled flag evaluation test scenarios
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
1 parent b507289 commit e13251e

3 files changed

Lines changed: 108 additions & 0 deletions

File tree

flags/disabled-flags.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"flags": {
3+
"disabled-boolean-flag": {
4+
"state": "DISABLED",
5+
"variants": {
6+
"on": true,
7+
"off": false
8+
},
9+
"defaultVariant": "on"
10+
},
11+
"disabled-string-flag": {
12+
"state": "DISABLED",
13+
"variants": {
14+
"greeting": "hi",
15+
"parting": "bye"
16+
},
17+
"defaultVariant": "greeting"
18+
},
19+
"disabled-integer-flag": {
20+
"state": "DISABLED",
21+
"variants": {
22+
"one": 1,
23+
"ten": 10
24+
},
25+
"defaultVariant": "ten"
26+
},
27+
"disabled-float-flag": {
28+
"state": "DISABLED",
29+
"variants": {
30+
"tenth": 0.1,
31+
"half": 0.5
32+
},
33+
"defaultVariant": "half"
34+
},
35+
"disabled-object-flag": {
36+
"state": "DISABLED",
37+
"variants": {
38+
"empty": {},
39+
"template": {
40+
"showImages": true,
41+
"title": "Check out these pics!",
42+
"imagesPerPage": 100
43+
}
44+
},
45+
"defaultVariant": "template"
46+
},
47+
"cross-flagset-flag": {
48+
"state": "DISABLED",
49+
"variants": {
50+
"on": true,
51+
"off": false
52+
},
53+
"defaultVariant": "on"
54+
}
55+
}
56+
}

flags/selector-flags.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
"bar": "bar"
88
},
99
"defaultVariant": "foo"
10+
},
11+
"cross-flagset-flag": {
12+
"state": "ENABLED",
13+
"variants": {
14+
"on": true,
15+
"off": false
16+
},
17+
"defaultVariant": "on"
1018
}
1119
}
1220
}

gherkin/disabled.feature

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Feature: Disabled flag evaluation
2+
3+
# Test coverage for disabled flag behavior. A flag with state=DISABLED resolves
4+
# successfully with reason=DISABLED and no value or variant (SDK uses code default).
5+
# Relates to: https://github.com/open-feature/flagd/issues/1965
6+
7+
@rpc @in-process
8+
Scenario Outline: Evaluating a disabled flag returns reason DISABLED and code default
9+
Given an option "cache" of type "CacheType" with value "disabled"
10+
And a stable flagd provider
11+
And a <type>-flag with key "<key>" and a default value "<default>"
12+
When the flag was evaluated with details
13+
Then the resolved details value should be "<default>"
14+
And the reason should be "DISABLED"
15+
16+
Examples:
17+
| key | type | default |
18+
| disabled-boolean-flag | Boolean | false |
19+
| disabled-string-flag | String | bye |
20+
| disabled-integer-flag | Integer | 1 |
21+
| disabled-float-flag | Float | 0.1 |
22+
23+
@rpc
24+
Scenario: Bulk evaluation includes disabled flags with reason DISABLED
25+
Given an option "cache" of type "CacheType" with value "disabled"
26+
And a stable flagd provider
27+
When all flags were evaluated in bulk
28+
Then the bulk evaluation result should contain a flag with key "disabled-boolean-flag" and reason "DISABLED"
29+
And the bulk evaluation result should contain a flag with key "boolean-flag" and reason "STATIC"
30+
31+
@in-process
32+
Scenario Outline: Flag disabled in one flag set, enabled in another
33+
Given an option "cache" of type "CacheType" with value "disabled"
34+
And an option "selector" of type "String" with value "<selector>"
35+
And a stable flagd provider
36+
And a Boolean-flag with key "cross-flagset-flag" and a default value "false"
37+
When the flag was evaluated with details
38+
Then the resolved details value should be "<resolved_value>"
39+
And the reason should be "<reason>"
40+
41+
Examples:
42+
| selector | resolved_value | reason |
43+
| rawflags/disabled-flags.json | false | DISABLED |
44+
| rawflags/selector-flags.json | true | STATIC |

0 commit comments

Comments
 (0)