From 81328e4922ea10bf39721905a1c75d9743e5002a Mon Sep 17 00:00:00 2001 From: lea konvalinka Date: Thu, 2 Apr 2026 17:03:02 +0200 Subject: [PATCH 1/3] test: add PARSE_ERROR and whitespace tests for evaluator ref Signed-off-by: Lea Konvalinka --- flags/evaluator-refs.json | 72 +++++++++++++++++++++++++++++++++++++++ gherkin/targeting.feature | 24 +++++++++++++ 2 files changed, 96 insertions(+) diff --git a/flags/evaluator-refs.json b/flags/evaluator-refs.json index faad954..b2ca516 100644 --- a/flags/evaluator-refs.json +++ b/flags/evaluator-refs.json @@ -35,6 +35,78 @@ "no" ] } + }, + "ref-whitespace-compact-flag": { + "state": "ENABLED", + "variants": { + "hi": "hi", + "bye": "bye", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref":"is_ballmer" + }, + "hi", + "bye" + ] + } + }, + "ref-whitespace-space-after-colon-flag": { + "state": "ENABLED", + "variants": { + "hi": "hi", + "bye": "bye", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref": "is_ballmer" + }, + "hi", + "bye" + ] + } + }, + "ref-whitespace-space-around-colon-flag": { + "state": "ENABLED", + "variants": { + "hi": "hi", + "bye": "bye", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref" : "is_ballmer" + }, + "hi", + "bye" + ] + } + }, + "ref-to-nonexistent-evaluator-flag": { + "state": "ENABLED", + "variants": { + "hit": "hit", + "miss": "miss", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref": "nonexistent_evaluator" + }, + "hit", + "miss" + ] + } } }, "$evaluators": { diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index 71fb8b0..8c29250 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -20,6 +20,30 @@ Feature: Targeting rules | some-email-targeted-flag | hi | | some-other-email-targeted-flag | yes | + @evaluator-refs @evaluator-refs-whitespace + Scenario Outline: Evaluator $ref resolves regardless of whitespace around the colon + Given a String-flag with key "" and a default value "fallback" + And a context containing a key "email", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + And the reason should be "TARGETING_MATCH" + Examples: + | key | email | value | + | ref-whitespace-compact-flag | ballmer@macrosoft.com | hi | + | ref-whitespace-space-after-colon-flag | ballmer@macrosoft.com | hi | + | ref-whitespace-space-around-colon-flag | ballmer@macrosoft.com | hi | + | ref-whitespace-compact-flag | user@example.com | bye | + | ref-whitespace-space-after-colon-flag | user@example.com | bye | + | ref-whitespace-space-around-colon-flag | user@example.com | bye | + + @evaluator-refs + Scenario: Ref to nonexistent evaluator yields parse error + Given a String-flag with key "ref-to-nonexistent-evaluator-flag" and a default value "fallback" + When the flag was evaluated with details + Then the resolved details value should be "fallback" + And the error-code should be "PARSE_ERROR" + And the error message should contain "nonexistent_evaluator" + # custom operators # @fractional-v1: legacy float-based bucketing (abs(hash) / i32::MAX * 100) # @fractional-v2: high-precision integer bucketing ((hash * totalWeight) >> 32) From 1a732d367ce8b5940d8bac056faa089837fe8ea8 Mon Sep 17 00:00:00 2001 From: lea konvalinka Date: Fri, 3 Apr 2026 10:19:22 +0200 Subject: [PATCH 2/3] fix: add tests to evaluator suite as well Signed-off-by: Lea Konvalinka --- evaluator/flags/testkit-flags.json | 72 ++++++++++++++++++++++++ evaluator/gherkin/evaluator-refs.feature | 24 ++++++++ gherkin/targeting.feature | 2 +- 3 files changed, 97 insertions(+), 1 deletion(-) diff --git a/evaluator/flags/testkit-flags.json b/evaluator/flags/testkit-flags.json index ce24194..fc696d4 100644 --- a/evaluator/flags/testkit-flags.json +++ b/evaluator/flags/testkit-flags.json @@ -511,6 +511,78 @@ "targeting": { "if": [{"sem_ver": [{"var": "version"}, "=", "1.0.0+build"]}, "match", "no-match"] } + }, + "ref-whitespace-compact-flag": { + "state": "ENABLED", + "variants": { + "hi": "hi", + "bye": "bye", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref":"is_ballmer" + }, + "hi", + "bye" + ] + } + }, + "ref-whitespace-space-after-colon-flag": { + "state": "ENABLED", + "variants": { + "hi": "hi", + "bye": "bye", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref": "is_ballmer" + }, + "hi", + "bye" + ] + } + }, + "ref-whitespace-space-around-colon-flag": { + "state": "ENABLED", + "variants": { + "hi": "hi", + "bye": "bye", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref" : "is_ballmer" + }, + "hi", + "bye" + ] + } + }, + "ref-to-nonexistent-evaluator-flag": { + "state": "ENABLED", + "variants": { + "hit": "hit", + "miss": "miss", + "fallback": "fallback" + }, + "defaultVariant": "fallback", + "targeting": { + "if": [ + { + "$ref": "nonexistent_evaluator" + }, + "hit", + "miss" + ] + } } }, "$evaluators": { diff --git a/evaluator/gherkin/evaluator-refs.feature b/evaluator/gherkin/evaluator-refs.feature index 0d8467d..997dd1c 100644 --- a/evaluator/gherkin/evaluator-refs.feature +++ b/evaluator/gherkin/evaluator-refs.feature @@ -13,3 +13,27 @@ Feature: Evaluator evaluator refs | key | value | | some-email-targeted-flag | hi | | some-other-email-targeted-flag | yes | + + @evaluator-refs @evaluator-refs-whitespace + Scenario Outline: Evaluator $ref resolves regardless of whitespace around the colon + Given a String-flag with key "" and a default value "fallback" + And a context containing a key "email", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + And the reason should be "TARGETING_MATCH" + Examples: + | key | email | value | + | ref-whitespace-compact-flag | ballmer@macrosoft.com | hi | + | ref-whitespace-space-after-colon-flag | ballmer@macrosoft.com | hi | + | ref-whitespace-space-around-colon-flag | ballmer@macrosoft.com | hi | + | ref-whitespace-compact-flag | user@example.com | bye | + | ref-whitespace-space-after-colon-flag | user@example.com | bye | + | ref-whitespace-space-around-colon-flag | user@example.com | bye | + + @evaluator-refs @non-existent-evaluator-ref + Scenario: Ref to nonexistent evaluator yields parse error + Given a String-flag with key "ref-to-nonexistent-evaluator-flag" and a default value "fallback" + When the flag was evaluated with details + Then the resolved details value should be "fallback" + And the error-code should be "PARSE_ERROR" + And the error message should contain "nonexistent_evaluator" diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index 8c29250..fedb4d7 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -36,7 +36,7 @@ Feature: Targeting rules | ref-whitespace-space-after-colon-flag | user@example.com | bye | | ref-whitespace-space-around-colon-flag | user@example.com | bye | - @evaluator-refs + @evaluator-refs @non-existent-evaluator-ref Scenario: Ref to nonexistent evaluator yields parse error Given a String-flag with key "ref-to-nonexistent-evaluator-flag" and a default value "fallback" When the flag was evaluated with details From e97da10a52672954fa78b5ba3059f96623dd05dc Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Thu, 9 Apr 2026 16:26:19 -0400 Subject: [PATCH 3/3] fix: drop error-message step and fix evaluator gherkin conventions Remove 'error message should contain' step (new step def, adds friction). Fix evaluator suite to use 'a fallback value' instead of 'a default value'. Add missing 'Given an evaluator' to new evaluator scenarios. Signed-off-by: Todd Baert --- evaluator/gherkin/evaluator-refs.feature | 7 ++++--- gherkin/targeting.feature | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/evaluator/gherkin/evaluator-refs.feature b/evaluator/gherkin/evaluator-refs.feature index 997dd1c..1e2ffd4 100644 --- a/evaluator/gherkin/evaluator-refs.feature +++ b/evaluator/gherkin/evaluator-refs.feature @@ -16,7 +16,8 @@ Feature: Evaluator evaluator refs @evaluator-refs @evaluator-refs-whitespace Scenario Outline: Evaluator $ref resolves regardless of whitespace around the colon - Given a String-flag with key "" and a default value "fallback" + Given an evaluator + And a String-flag with key "" and a fallback value "fallback" And a context containing a key "email", with type "String" and with value "" When the flag was evaluated with details Then the resolved details value should be "" @@ -32,8 +33,8 @@ Feature: Evaluator evaluator refs @evaluator-refs @non-existent-evaluator-ref Scenario: Ref to nonexistent evaluator yields parse error - Given a String-flag with key "ref-to-nonexistent-evaluator-flag" and a default value "fallback" + Given an evaluator + And a String-flag with key "ref-to-nonexistent-evaluator-flag" and a fallback value "fallback" When the flag was evaluated with details Then the resolved details value should be "fallback" And the error-code should be "PARSE_ERROR" - And the error message should contain "nonexistent_evaluator" diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index fedb4d7..8a193b9 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -42,7 +42,6 @@ Feature: Targeting rules When the flag was evaluated with details Then the resolved details value should be "fallback" And the error-code should be "PARSE_ERROR" - And the error message should contain "nonexistent_evaluator" # custom operators # @fractional-v1: legacy float-based bucketing (abs(hash) / i32::MAX * 100)