From c673bf0fb6efca9d9675dd751ddd4459f87d86b4 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Fri, 28 Jun 2024 14:43:13 -0400 Subject: [PATCH] feat: fractional non-percentage and shorthand (#132) Signed-off-by: Todd Baert --- flags/custom-ops.json | 15 +++++++++++++++ gherkin/flagd-json-evaluator.feature | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/flags/custom-ops.json b/flags/custom-ops.json index 6b420ee..11148ff 100644 --- a/flags/custom-ops.json +++ b/flags/custom-ops.json @@ -23,6 +23,21 @@ ] } }, + "fractional-flag-shorthand": { + "state": "ENABLED", + "variants": { + "heads": "heads", + "tails": "tails", + "draw": "draw" + }, + "defaultVariant": "draw", + "targeting": { + "fractional": [ + [ "heads" ], + [ "tails", 1 ] + ] + } + }, "fractional-flag-A-shared-seed": { "state": "ENABLED", "variants": { diff --git a/gherkin/flagd-json-evaluator.feature b/gherkin/flagd-json-evaluator.feature index 72e4eb1..ac7096b 100644 --- a/gherkin/flagd-json-evaluator.feature +++ b/gherkin/flagd-json-evaluator.feature @@ -30,6 +30,15 @@ Feature: flagd json evaluation | "nine" | "hearts" | | 3 | "diamonds" | + Scenario Outline: Fractional operator shorthand + When a string flag with key "fractional-flag-shorthand" is evaluated with default value "fallback" + And a context containing a targeting key with value + Then the returned value should be + Examples: + | targeting key | value | + | "jane@company.com" | "heads" | + | "joe@company.com" | "tails" | + Scenario Outline: Fractional operator with shared seed When a string flag with key "fractional-flag-A-shared-seed" is evaluated with default value "fallback" And a context containing a nested property with outer key "user" and inner key "name", with value @@ -46,7 +55,7 @@ Feature: flagd json evaluation And a context containing a nested property with outer key "user" and inner key "name", with value Then the returned value should be Examples: - | name | value | + | name | value | | "jack" | "ace-of-hearts" | | "queen" | "ace-of-spades" | | "ten" | "ace-of-hearts" |