Skip to content
Closed
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
92 changes: 92 additions & 0 deletions evaluator/flags/testkit-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,92 @@
null
]
}
},
"fractional-hash-edge-flag": {
"state": "ENABLED",
"variants": { "lower": "lower", "upper": "upper" },
"defaultVariant": "lower",
"targeting": {
"fractional": [
{ "var": "targetingKey" },
[ "lower", 50 ],
[ "upper", 50 ]
]
}
},
"semver-v-prefix-flag": {
"state": "ENABLED",
"variants": { "match": "match", "no-match": "no-match" },
"defaultVariant": "no-match",
"targeting": { "if": [{"sem_ver": [{"var": "version"}, "=", "v1.0.0"]}, "match", "no-match"] }
},
"semver-partial-version-flag": {
"state": "ENABLED",
"variants": { "match": "match", "no-match": "no-match" },
"defaultVariant": "no-match",
"targeting": { "if": [{"sem_ver": [{"var": "version"}, "^", "1"]}, "match", "no-match"] }
},
"semver-build-metadata-flag": {
"state": "ENABLED",
"variants": { "match": "match", "no-match": "no-match" },
"defaultVariant": "no-match",
"targeting": { "if": [{"sem_ver": [{"var": "version"}, "=", "1.0.0+build"]}, "match", "no-match"] }
},
"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]
]
}
},
"nested-ref-targeted-flag": {
"state": "ENABLED",
"variants": { "privileged": "privileged", "standard": "standard", "none": "none" },
"defaultVariant": "none",
"targeting": {
"if": [{"$ref": "is_privileged"}, "privileged", "standard"]
}
},
"fractional-nested-if-flag": {
"state": "ENABLED",
"variants": { "premium": "premium", "standard": "standard", "fallback": "fallback" },
"defaultVariant": "fallback",
"targeting": {
"fractional": [
{ "var": "targetingKey" },
[{"if": [{"==": [{"var": "tier"}, "premium"]}, "premium", "standard"]}, 50],
[ "standard", 50 ]
]
}
},
"fractional-nested-var-flag": {
"state": "ENABLED",
"variants": { "red": "red", "green": "green", "blue": "blue", "fallback": "fallback" },
"defaultVariant": "fallback",
"targeting": {
"fractional": [
{ "var": "targetingKey" },
[ { "var": "color" }, 50 ],
[ "blue", 50 ]
]
}
}
},
"$evaluators": {
Expand All @@ -394,6 +480,12 @@
"ballmer@macrosoft.com",
{"var": ["email"]}
]
},
"is_privileged": {
"or": [
{"$ref": "is_ballmer"},
{"==": ["admin", {"var": ["role"]}]}
]
}
}
}
16 changes: 16 additions & 0 deletions evaluator/gherkin/evaluator-refs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ Feature: Evaluator evaluator refs
| key | value |
| some-email-targeted-flag | hi |
| some-other-email-targeted-flag | yes |

# Nested $ref resolution — is_privileged references is_ballmer.
# Use -t "not @evaluator-ref-edge-cases" to exclude during transition.
@evaluator-ref-edge-cases
Scenario Outline: Nested evaluator ref resolution
Given an evaluator
And a String-flag with key "nested-ref-targeted-flag" and a fallback value "fallback"
And a context containing a key "<context_key>", with type "String" and with value "<context_value>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"

Examples:
| context_key | context_value | value |
| email | ballmer@macrosoft.com | privileged |
| role | admin | privileged |
| email | other@example.com | standard |
39 changes: 39 additions & 0 deletions evaluator/gherkin/fractional.feature
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,42 @@ Feature: Evaluator fractional operator
| SI7p- | lower |
| 6LvT0 | upper |
| ceQdGm | upper |

# Nested JSON Logic expressions as bucket variant names.
# Use -t "not @fractional-nested" to exclude during transition.
@fractional-nested
Scenario Outline: Fractional operator with nested if expression as variant name
Given a String-flag with key "fractional-nested-if-flag" and a fallback value "fallback"
And a context containing a targeting key with value "<targetingKey>"
And a context containing a key "tier", with type "String" and with value "<tier>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"

Examples:
| targetingKey | tier | value |
| jon@company.com | premium | premium |
| jon@company.com | basic | standard |
| user1 | premium | standard |
| user1 | basic | standard |

@fractional-nested
Scenario Outline: Fractional operator with nested var expression as variant name
Given a String-flag with key "fractional-nested-var-flag" and a fallback value "fallback"
And a context containing a targeting key with value "<targetingKey>"
And a context containing a key "color", with type "String" and with value "<color>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"

Examples:
| targetingKey | color | value |
| jon@company.com | red | red |
| jon@company.com | green | green |
| user1 | red | blue |
| jon@company.com | yellow | fallback |
| jon@company.com | | fallback |

@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 fallback value "wrong"
When the flag was evaluated with details
Then the resolved details value should be "fallback"
53 changes: 53 additions & 0 deletions evaluator/gherkin/semver.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,56 @@ Feature: Evaluator semantic version operator
| 3.0.1 | minor |
| 3.1.0 | major |
| 4.0.0 | none |

# Edge cases: v-prefix, partial versions, build metadata.
# Use -t "not @semver-edge-cases" to exclude during transition.
@semver-edge-cases
Scenario Outline: sem_ver v-prefix handling
Given a String-flag with key "semver-v-prefix-flag" and a fallback value "fallback"
And a context containing a key "version", with type "String" and with value "<version>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"

Examples:
| version | value |
| 1.0.0 | match |
| v1.0.0 | match |
| 2.0.0 | no-match |

@semver-edge-cases
Scenario Outline: sem_ver partial version handling
Given a String-flag with key "semver-partial-version-flag" and a fallback value "fallback"
And a context containing a key "version", with type "String" and with value "<version>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"

Examples:
| version | value |
| 1.5.0 | match |
| 1.0.0 | match |
| 2.0.0 | no-match |

@semver-edge-cases
Scenario Outline: sem_ver build metadata ignored
Given a String-flag with key "semver-build-metadata-flag" and a fallback value "fallback"
And a context containing a key "version", with type "String" and with value "<version>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"

Examples:
| version | value |
| 1.0.0 | match |
| 1.0.0+other | match |
| 2.0.0 | no-match |

@operator-errors
Scenario Outline: sem_ver operator errors return null and fall back to default variant
Given 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 "<value>"

Examples:
| key | context_value | value |
| semver-invalid-version-flag | not-a-version | fallback |
| semver-invalid-operator-flag | 1.0.0 | fallback |
Loading