diff --git a/evaluator/flags/testkit-flags.json b/evaluator/flags/testkit-flags.json index 268e905..38c9be5 100644 --- a/evaluator/flags/testkit-flags.json +++ b/evaluator/flags/testkit-flags.json @@ -474,6 +474,30 @@ ["two", 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"] + } } }, "$evaluators": { diff --git a/evaluator/gherkin/semver.feature b/evaluator/gherkin/semver.feature index 0b215c7..6bb2c13 100644 --- a/evaluator/gherkin/semver.feature +++ b/evaluator/gherkin/semver.feature @@ -43,3 +43,42 @@ Feature: Evaluator semantic version operator | key | context_value | | semver-invalid-version-flag | not-a-version | | semver-invalid-operator-flag | 1.0.0 | + + @semver-edge-cases @semver-v-prefix + Scenario Outline: v-prefix handling + Given an evaluator + And 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 "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.0.0 | match | + | v1.0.0 | match | + | 2.0.0 | no-match | + + @semver-edge-cases @semver-partial-version + Scenario Outline: partial version handling + Given an evaluator + And 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 "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.5.0 | match | + | 1.0.0 | match | + | 2.0.0 | no-match | + + @semver-edge-cases @semver-build-metadata + Scenario Outline: build metadata ignored in comparison + Given an evaluator + And 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 "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.0.0 | match | + | 1.0.0+other | match | + | 2.0.0 | no-match | diff --git a/flags/custom-ops.json b/flags/custom-ops.json index 85f5f9a..84b1a94 100644 --- a/flags/custom-ops.json +++ b/flags/custom-ops.json @@ -299,6 +299,48 @@ } ] } + }, + "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" + ] + } } } } diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index 5dd7ae2..cd29f9d 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -240,6 +240,42 @@ Feature: Targeting rules | 3.1.0 | major | | 4.0.0 | none | + @semver @semver-edge-cases @semver-v-prefix + Scenario Outline: sem_ver v-prefix handling + Given a String-flag with key "semver-v-prefix-flag" and a default value "fallback" + And a context containing a key "version", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.0.0 | match | + | v1.0.0 | match | + | 2.0.0 | no-match | + + @semver @semver-edge-cases @semver-partial-version + Scenario Outline: sem_ver partial version handling + Given a String-flag with key "semver-partial-version-flag" and a default value "fallback" + And a context containing a key "version", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.5.0 | match | + | 1.0.0 | match | + | 2.0.0 | no-match | + + @semver @semver-edge-cases @semver-build-metadata + Scenario Outline: sem_ver build metadata ignored + Given a String-flag with key "semver-build-metadata-flag" and a default value "fallback" + And a context containing a key "version", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.0.0 | match | + | 1.0.0+other | match | + | 2.0.0 | no-match | + Scenario Outline: Time-based operations Given a Integer-flag with key "timestamp-flag" and a default value "0" And a context containing a key "time", with type "Integer" and with value "