-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Schrottner <[email protected]>
- Loading branch information
Showing
5 changed files
with
151 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,118 +9,129 @@ Feature: flagd json evaluation | |
|
||
# evaluator refs | ||
Scenario Outline: Evaluator reuse | ||
When a string flag with key <key> is evaluated with default value "fallback" | ||
And a context containing a key "email", with value "[email protected]" | ||
Then the returned value should be <value> | ||
Given a String-flag with key "<key>" and a default value "fallback" | ||
And a context containing a key "email", with type "String" and with value "[email protected]" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| key | value | | ||
| "some-email-targeted-flag" | "hi" | | ||
| "some-other-email-targeted-flag" | "yes" | | ||
| key | value | | ||
| some-email-targeted-flag | hi | | ||
| some-other-email-targeted-flag | yes | | ||
|
||
# custom operators | ||
Scenario Outline: Fractional operator | ||
When a string flag with key "fractional-flag" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag" and a default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value "<name>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| name | value | | ||
| "jack" | "spades" | | ||
| "queen" | "clubs" | | ||
| "ten" | "diamonds" | | ||
| "nine" | "hearts" | | ||
| 3 | "diamonds" | | ||
| name | value | | ||
| jack | spades | | ||
| queen | clubs | | ||
| ten | diamonds | | ||
| nine | hearts | | ||
| 3 | diamonds | | ||
|
||
Scenario Outline: Fractional operator shorthand | ||
When a string flag with key "fractional-flag-shorthand" is evaluated with default value "fallback" | ||
And a context containing a targeting key with value <targeting key> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag-shorthand" and a default value "fallback" | ||
And a context containing a targeting key with value "<targeting key>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| targeting key | value | | ||
| "jon@company.com" | "heads" | | ||
| "jane@company.com" | "tails" | | ||
| targeting key | value | | ||
| jon@company.com | heads | | ||
| jane@company.com | tails | | ||
|
||
Scenario Outline: Fractional operator with shared seed | ||
When a string flag with key "fractional-flag-A-shared-seed" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag-A-shared-seed" and a default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value "<name>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| name | value | | ||
| "jack" | "hearts" | | ||
| "queen" | "spades" | | ||
| "ten" | "hearts" | | ||
| "nine" | "diamonds" | | ||
| name | value | | ||
| jack | hearts | | ||
| queen | spades | | ||
| ten | hearts | | ||
| nine | diamonds | | ||
|
||
Scenario Outline: Second fractional operator with shared seed | ||
When a string flag with key "fractional-flag-B-shared-seed" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag-B-shared-seed" and a default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value "<name>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| name | value | | ||
| "jack" | "ace-of-hearts" | | ||
| "queen" | "ace-of-spades" | | ||
| "ten" | "ace-of-hearts" | | ||
| "nine" | "ace-of-diamonds" | | ||
| name | value | | ||
| jack | ace-of-hearts | | ||
| queen | ace-of-spades | | ||
| ten | ace-of-hearts | | ||
| nine | ace-of-diamonds | | ||
|
||
Scenario Outline: Substring operators | ||
When a string flag with key "starts-ends-flag" is evaluated with default value "fallback" | ||
And a context containing a key "id", with value <id> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "starts-ends-flag" and a default value "fallback" | ||
And a context containing a key "id", with type "String" and with value "<id>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| id | value | | ||
| "abcdef" | "prefix" | | ||
| "uvwxyz" | "postfix" | | ||
| "abcxyz" | "prefix" | | ||
| "lmnopq" | "none" | | ||
| 3 | "none" | | ||
| id | value | | ||
| abcdef | prefix | | ||
| uvwxyz | postfix | | ||
| abcxyz | prefix | | ||
| lmnopq | none | | ||
| 3 | none | | ||
|
||
Scenario Outline: Semantic version operator numeric comparison | ||
When a string flag with key "equal-greater-lesser-version-flag" is evaluated with default value "fallback" | ||
And a context containing a key "version", with value <version> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "equal-greater-lesser-version-flag" and a default 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 | | ||
| "2.0.0" | "equal" | | ||
| "2.1.0" | "greater" | | ||
| "1.9.0" | "lesser" | | ||
| "2.0.0-alpha" | "lesser" | | ||
| "2.0.0.0" | "none" | | ||
| version | value | | ||
| 2.0.0 | equal | | ||
| 2.1.0 | greater | | ||
| 1.9.0 | lesser | | ||
| 2.0.0-alpha | lesser | | ||
| 2.0.0.0 | none | | ||
|
||
Scenario Outline: Semantic version operator semantic comparison | ||
When a string flag with key "major-minor-version-flag" is evaluated with default value "fallback" | ||
And a context containing a key "version", with value <version> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "major-minor-version-flag" and a default 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 | | ||
| "3.0.1" | "minor" | | ||
| "3.1.0" | "major" | | ||
| "4.0.0" | "none" | | ||
| version | value | | ||
| 3.0.1 | minor | | ||
| 3.1.0 | major | | ||
| 4.0.0 | none | | ||
|
||
Scenario Outline: Time-based operations | ||
When an integer flag with key "timestamp-flag" is evaluated with default value 0 | ||
And a context containing a key "time", with value <time> | ||
Then the returned value should be <value> | ||
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 "<time>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| time | value | | ||
| 1 | -1 | | ||
| 4133980802 | 1 | | ||
|
||
Scenario Outline: Targeting by targeting key | ||
When a string flag with key "targeting-key-flag" is evaluated with default value "fallback" | ||
And a context containing a targeting key with value <targeting key> | ||
Then the returned value should be <value> | ||
Then the returned reason should be <reason> | ||
Given a String-flag with key "targeting-key-flag" and a default value "fallback" | ||
And a context containing a targeting key with value "<targeting key>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Then the reason should be "<reason>" | ||
Examples: | ||
| targeting key | value | reason | | ||
| "5c3d8535-f81a-4478-a6d3-afaa4d51199e" | "hit" | "TARGETING_MATCH" | | ||
| "f20bd32d-703b-48b6-bc8e-79d53c85134a" | "miss" | "DEFAULT" | | ||
| targeting key | value | reason | | ||
| 5c3d8535-f81a-4478-a6d3-afaa4d51199e | hit | TARGETING_MATCH | | ||
| f20bd32d-703b-48b6-bc8e-79d53c85134a | miss | DEFAULT | | ||
|
||
Scenario Outline: Errors and edge cases | ||
When an integer flag with key <key> is evaluated with default value 3 | ||
Then the returned value should be <value> | ||
Given a Integer-flag with key "<key>" and a default value "3" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| key | value | | ||
| "targeting-null-variant-flag" | 2 | | ||
| "error-targeting-flag" | 3 | | ||
| "missing-variant-targeting-flag" | 3 | | ||
| "non-string-variant-targeting-flag" | 2 | | ||
| "empty-targeting-flag" | 1 | | ||
| key | value | | ||
| targeting-null-variant-flag | 2 | | ||
| error-targeting-flag | 3 | | ||
| missing-variant-targeting-flag | 3 | | ||
| non-string-variant-targeting-flag | 2 | | ||
| empty-targeting-flag | 1 | |
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