Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions evaluator/flags/testkit-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,34 @@
"small"
]
}
},
"semver-invalid-version-flag": {
"state": "ENABLED",
"variants": { "match": "match", "no-match": "no-match", "fallback": "fallback" },
"defaultVariant": "fallback",
"targeting": {
"sem_ver": [{"var": "version"}, "=", "1.0.0"]
}
},
"semver-invalid-operator-flag": {
"state": "ENABLED",
"variants": { "match": "match", "no-match": "no-match", "fallback": "fallback" },
"defaultVariant": "fallback",
"targeting": {
"sem_ver": [{"var": "version"}, "===", "1.0.0"]
}
},
"fractional-null-bucket-key-flag": {
"state": "ENABLED",
"variants": { "one": "one", "two": "two", "fallback": "fallback" },
"defaultVariant": "fallback",
"targeting": {
"fractional": [
{"var": "missing_key"},
["one", 50],
["two", 50]
]
}
}
},
"$evaluators": {
Expand Down
7 changes: 7 additions & 0 deletions evaluator/gherkin/fractional.feature
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,10 @@ Feature: Evaluator fractional operator
And a context containing a targeting key with value "some-targeting-key"
When the flag was evaluated with details
Then the resolved details value should be "ones"

@operator-errors
Scenario: fractional operator with missing bucket key falls back to default variant
Given an evaluator
And a String-flag with key "fractional-null-bucket-key-flag" and a fallback value "wrong"
When the flag was evaluated with details
Then the resolved details value should be "fallback"
12 changes: 12 additions & 0 deletions evaluator/gherkin/semver.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ Feature: Evaluator semantic version operator
| 3.0.1 | minor |
| 3.1.0 | major |
| 4.0.0 | none |

@operator-errors
Scenario Outline: sem_ver returns null for invalid input and falls back to default variant
Given an evaluator
And a String-flag with key "<key>" and a fallback value "wrong"
And a context containing a key "version", with type "String" and with value "<context_value>"
When the flag was evaluated with details
Then the resolved details value should be "fallback"
Examples:
| key | context_value |
| semver-invalid-version-flag | not-a-version |
| semver-invalid-operator-flag | 1.0.0 |
40 changes: 40 additions & 0 deletions flags/edge-case-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,46 @@
},
"defaultVariant": "false",
"targeting": {}
},
"semver-invalid-version-flag": {
"state": "ENABLED",
"variants": {
"match": "match",
"no-match": "no-match",
"fallback": "fallback"
},
"defaultVariant": "fallback",
"targeting": {
"sem_ver": [{"var": "version"}, "=", "1.0.0"]
}
},
"semver-invalid-operator-flag": {
"state": "ENABLED",
"variants": {
"match": "match",
"no-match": "no-match",
"fallback": "fallback"
},
"defaultVariant": "fallback",
"targeting": {
"sem_ver": [{"var": "version"}, "===", "1.0.0"]
}
},
"fractional-null-bucket-key-flag": {
"state": "ENABLED",
"variants": {
"one": "one",
"two": "two",
"fallback": "fallback"
},
"defaultVariant": "fallback",
"targeting": {
"fractional": [
{"var": "missing_key"},
["one", 50],
["two", 50]
]
}
}
}
}
17 changes: 17 additions & 0 deletions gherkin/targeting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,20 @@ Feature: Targeting rules
| missing-variant-targeting-flag | 3 | GENERAL |
| non-string-variant-targeting-flag | 2 | |
| empty-targeting-flag | 1 | |

@operator-errors
Scenario Outline: Custom operator errors return null and fall back to default variant
Given a String-flag with key "<key>" and a default value "wrong"
And a context containing a key "version", with type "String" and with value "<context_value>"
When the flag was evaluated with details
Then the resolved details value should be "fallback"
Examples:
| key | context_value |
| semver-invalid-version-flag | not-a-version |
| semver-invalid-operator-flag | 1.0.0 |

@operator-errors
Scenario: fractional operator with missing bucket key falls back to default variant
Given a String-flag with key "fractional-null-bucket-key-flag" and a default value "wrong"
When the flag was evaluated with details
Then the resolved details value should be "fallback"
Loading