From db439774595a8f430cda82c452eaf31ff9fb836b Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Tue, 13 Feb 2024 07:59:57 -0500 Subject: [PATCH] feat: provider unavailable, targeting key tests (#103) Signed-off-by: Todd Baert --- flags/testing-flags.json | 17 +++++++++++++++++ gherkin/flagd-json-evaluator.feature | 10 ++++++++++ gherkin/flagd-reconnect.feature | 7 ++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/flags/testing-flags.json b/flags/testing-flags.json index 981bb04..fb0ebd1 100644 --- a/flags/testing-flags.json +++ b/flags/testing-flags.json @@ -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 + ] + } } } } diff --git a/gherkin/flagd-json-evaluator.feature b/gherkin/flagd-json-evaluator.feature index 6e737ce..00105cb 100644 --- a/gherkin/flagd-json-evaluator.feature +++ b/gherkin/flagd-json-evaluator.feature @@ -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 + Then the returned value should be + Then the returned reason should be + 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 is evaluated with default value 3 Then the returned value should be diff --git a/gherkin/flagd-reconnect.feature b/gherkin/flagd-reconnect.feature index 17ff327..463d2bd 100644 --- a/gherkin/flagd-reconnect.feature +++ b/gherkin/flagd-reconnect.feature @@ -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 @@ -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