diff --git a/flags/custom-ops.json b/flags/custom-ops.json index 45a8fe1..6b420ee 100644 --- a/flags/custom-ops.json +++ b/flags/custom-ops.json @@ -12,7 +12,56 @@ "defaultVariant": "wild", "targeting": { "fractional": [ - { "var": "user.name" }, + {"cat": [ + { "var": "$flagd.flagKey" }, + { "var": "user.name" } + ]}, + [ "clubs", 25 ], + [ "diamonds", 25 ], + [ "hearts", 25 ], + [ "spades", 25 ] + ] + } + }, + "fractional-flag-A-shared-seed": { + "state": "ENABLED", + "variants": { + "clubs": "clubs", + "diamonds": "diamonds", + "hearts": "hearts", + "spades": "spades", + "wild": "wild" + }, + "defaultVariant": "wild", + "targeting": { + "fractional": [ + { "cat": [ + "shared-seed", + { "var": "user.name" } + ]}, + [ "clubs", 25 ], + [ "diamonds", 25 ], + [ "hearts", 25 ], + [ "spades", 25 ] + ] + } + }, + "fractional-flag-B-shared-seed": { + "state": "ENABLED", + "variants": { + "clubs": "ace-of-clubs", + "diamonds": "ace-of-diamonds", + "hearts": "ace-of-hearts", + "spades": "ace-of-spades", + "wild": "wild" + }, + "defaultVariant": "wild", + "targeting": { + "fractional": [ + { "cat": [ + "shared-seed", + { "var": "user.name" } + ]}, [ "clubs", 25 ], [ "diamonds", 25 ], [ "hearts", 25 ], diff --git a/gherkin/flagd-json-evaluator.feature b/gherkin/flagd-json-evaluator.feature index 00105cb..72e4eb1 100644 --- a/gherkin/flagd-json-evaluator.feature +++ b/gherkin/flagd-json-evaluator.feature @@ -28,7 +28,29 @@ Feature: flagd json evaluation | "queen" | "clubs" | | "ten" | "diamonds" | | "nine" | "hearts" | - | 3 | "wild" | + | 3 | "diamonds" | + + 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 + Then the returned value should be + Examples: + | name | value | + | "jack" | "hearts" | + | "queen" | "spades" | + | "ten" | "hearts" | + | "nine" | "diamonds" | + + Scenario Outline: Second fractional operator with shared seed + When a string flag with key "fractional-flag-B-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 + Then the returned value should be + Examples: + | name | value | + | "jack" | "ace-of-hearts" | + | "queen" | "ace-of-spades" | + | "ten" | "ace-of-hearts" | + | "nine" | "ace-of-diamonds" | Scenario Outline: Substring operators When a string flag with key "starts-ends-flag" is evaluated with default value "fallback"