-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: allow custom seed when using targetingKey override for fractio…
…nal op (#1266) <!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> - no longer injects flagKey as seed for fractional op when user has provided custom targeting - updates schema to allow `cat` and other operations so that custom targeting can be properly seeded ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> #1264 ### Notes <!-- any additional notes for this PR --> ### Follow-up Tasks <!-- anything that is related to this PR but not done here should be noted under this section --> <!-- if there is a need for a new issue, please link it here --> ### How to test <!-- if applicable, add testing instructions under this section --> ```bash # unit tests make test # gherkin tests ./bin/flagd start -f file:test-harness/flags/testing-flags.json -f file:test-harness/flags/custom-ops.json -f file:test-harness/flags/evaluator-refs.json -f file:test-harness/flags/zero-flags.json make flagd-integration-test ``` --------- Signed-off-by: Cole Bailey <[email protected]> Signed-off-by: Cole Bailey <[email protected]> Signed-off-by: Kavindu Dodanduwa <[email protected]> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Kavindu Dodanduwa <[email protected]>
- Loading branch information
1 parent
0075932
commit f62bc72
Showing
18 changed files
with
224 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ func TestFractionalEvaluation(t *testing.T) { | |
}, | ||
{ | ||
"fractional": [ | ||
{"var": "email"}, | ||
{"cat": [{"var": "$flagd.flagKey"}, {"var": "email"}]}, | ||
[ | ||
"red", | ||
25 | ||
|
@@ -54,6 +54,34 @@ func TestFractionalEvaluation(t *testing.T) { | |
] | ||
}`), | ||
}, | ||
"customSeededHeaderColor": { | ||
State: "ENABLED", | ||
DefaultVariant: "red", | ||
Variants: map[string]any{ | ||
"red": "#FF0000", | ||
"blue": "#0000FF", | ||
"green": "#00FF00", | ||
"yellow": "#FFFF00", | ||
}, | ||
Targeting: []byte(`{ | ||
"if": [ | ||
{ | ||
"in": ["@faas.com", { | ||
"var": ["email"] | ||
}] | ||
}, | ||
{ | ||
"fractional": [ | ||
{"cat": ["my-seed", {"var": "email"}]}, | ||
["red",25], | ||
["blue",25], | ||
["green",25], | ||
["yellow",25] | ||
] | ||
}, null | ||
] | ||
}`), | ||
}, | ||
}, | ||
} | ||
|
||
|
@@ -106,6 +134,46 @@ func TestFractionalEvaluation(t *testing.T) { | |
expectedValue: "#00FF00", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected] with custom seed": { | ||
flags: flags, | ||
flagKey: "customSeededHeaderColor", | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "green", | ||
expectedValue: "#00FF00", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected] with custom seed": { | ||
flags: flags, | ||
flagKey: "customSeededHeaderColor", | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected] with custom seed": { | ||
flags: flags, | ||
flagKey: "customSeededHeaderColor", | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "green", | ||
expectedValue: "#00FF00", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected] with custom seed": { | ||
flags: flags, | ||
flagKey: "customSeededHeaderColor", | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "green", | ||
expectedValue: "#00FF00", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected] with different flag key": { | ||
flags: Flags{ | ||
Flags: map[string]model.Flag{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.