Skip to content

Commit

Permalink
feat: test multiple fractional flags with shared seed (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Bailey <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
  • Loading branch information
colebaileygit and toddbaert authored Apr 6, 2024
1 parent 620df72 commit 25544e4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
51 changes: 50 additions & 1 deletion flags/custom-ops.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ],
Expand Down
24 changes: 23 additions & 1 deletion gherkin/flagd-json-evaluator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>
Then the returned value should be <value>
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 <name>
Then the returned value should be <value>
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"
Expand Down

0 comments on commit 25544e4

Please sign in to comment.