Skip to content

Commit

Permalink
feat: provider unavailable, targeting key tests (#103)
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
  • Loading branch information
toddbaert authored Feb 13, 2024
1 parent 98d6620 commit db43977
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
17 changes: 17 additions & 0 deletions flags/testing-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@
"two": "dos"
},
"defaultVariant": "one"
},
"targeting-key-flag": {
"state": "ENABLED",
"variants": {
"miss": "miss",
"hit": "hit"
},
"defaultVariant": "miss",
"targeting": {
"if": [
{
"==": [ { "var": "targetingKey" }, "5c3d8535-f81a-4478-a6d3-afaa4d51199e" ]
},
"hit",
null
]
}
}
}
}
10 changes: 10 additions & 0 deletions gherkin/flagd-json-evaluator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ Feature: flagd json evaluation
| 1 | -1 |
| 4133980802 | 1 |

Scenario Outline: Targeting by targeting key
When a string flag with key "targeting-key-flag" is evaluated with default value "fallback"
And a context containing a targeting key with value <targeting key>
Then the returned value should be <value>
Then the returned reason should be <reason>
Examples:
| targeting key | value | reason |
| "5c3d8535-f81a-4478-a6d3-afaa4d51199e" | "hit" | "TARGETING_MATCH" |
| "f20bd32d-703b-48b6-bc8e-79d53c85134a" | "miss" | "DEFAULT" |

Scenario Outline: Errors and edge cases
When an integer flag with key <key> is evaluated with default value 3
Then the returned value should be <value>
Expand Down
7 changes: 6 additions & 1 deletion gherkin/flagd-reconnect.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: flagd provider reconnect functionality
Feature: flagd provider disconnect and reconnect functionality

# This test suite tests the reconnection functionality of flagd providers

Expand All @@ -8,3 +8,8 @@ Feature: flagd provider reconnect functionality
Then the PROVIDER_READY handler must run when the provider connects
And the PROVIDER_ERROR handler must run when the provider's connection is lost
And when the connection is reestablished the PROVIDER_READY handler must run again

Scenario: Provider unavailable
Given flagd is unavailable
When a flagd provider is set and initialization is awaited
Then an error should be indicated within the configured deadline

0 comments on commit db43977

Please sign in to comment.