Skip to content

Commit

Permalink
fixup: separate, add re-use test
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Sep 6, 2023
1 parent 2114a63 commit 5069501
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 49 deletions.
1 change: 1 addition & 0 deletions flagd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ ENTRYPOINT ["sh", "wrapper.sh", "./flagd", "start", \
"-f", "file:testing-flags.json", \
"-f", "file:changing-flag.json", \
"-f", "file:custom-ops.json", \
"-f", "file:evaluator-refs.json", \
"-f", "file:zero-flags.json"]
52 changes: 52 additions & 0 deletions flags/evaluator-refs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"flags": {
"some-email-targeted-flag": {
"state": "ENABLED",
"variants": {
"hi": "hi",
"bye": "bye",
"none": "none"
},
"defaultVariant": "none",
"targeting": {
"if": [
{
"$ref": "is_ballmer"
},
"hi",
"bye"
]
}
},
"some-other-email-targeted-flag": {
"state": "ENABLED",
"variants": {
"yes": "yes",
"no": "no",
"none": "none"
},
"defaultVariant": "none",
"targeting": {
"if": [
{
"$ref": "is_ballmer"
},
"yes",
"no"
]
}
}
},
"$evaluators": {
"is_ballmer": {
"==": [
"[email protected]",
{
"var": [
"email"
]
}
]
}
}
}
63 changes: 63 additions & 0 deletions gherkin/flagd-json-evaluator.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Feature: flagd json evaluation

# This test suite contains scenarios to test the json-evaluation of flagd and flag-in-process providers.
# It's associated with the flags configured in flags/changing-flag.json, flags/zero-flags.json, flags/custom-ops.json and evaluator-refs.json.
# It should be used in conjunection with the suites supplied by the OpenFeature specification.

Background:
Given a flagd provider is set

# 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>
Examples:
| 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>
Examples:
| name | value |
| jack | clubs |
| queen | diamonds |
| ace | hearts |
| joker | spades |

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>
Examples:
| id | value |
| abcdef | prefix |
| uvwxyz | postfix |
| abcxyz | prefix |
| lmnopq | nomatch |

Scenario Outline: Semantic version operator numeric comparision
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>
Examples:
| version | value |
| 2.0.0 | equal |
| 2.1.0 | greater |
| 1.9.0 | lesser |
| 2.0.0-alpha | lesser |
| 2.0.0.0 | invalid |

Scenario Outline: Semantic version operator semantic comparision
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>
Examples:
| version | value |
| 3.0.1 | minor |
| 3.1.0 | major |
| 4.0.0 | none |
53 changes: 4 additions & 49 deletions gherkin/flagd.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Feature: flagd providers

# This test suite contains scenarios to test flagd providers (both RPC and in-process).
# It's associated with the flags configured in flags/custom-ops.json and flags/zero-flags.json
# It should be used in conjunection with the suites supplied by the OpenFeature specification
# This test suite contains scenarios to test flagd providers.
# It's associated with the flags configured in flags/changing-flag.json and flags/zero-flags.json.
# It should be used in conjunection with the suites supplied by the OpenFeature specification.

Background:
Given a flagd provider is set
Expand Down Expand Up @@ -33,49 +33,4 @@ Feature: flagd providers

Scenario: Resolves float zero value
When a float flag with key "float-zero-flag" is evaluated with default value 0.1
Then the resolved float value should be 0.0

# 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>
Examples:
| name | value |
| jack | clubs |
| queen | diamonds |
| ace | hearts |
| joker | spades |

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>
Examples:
| id | value |
| abcdef | prefix |
| uvwxyz | postfix |
| abcxyz | prefix |
| lmnopq | nomatch |

Scenario Outline: Semantic version operator numeric comparision
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>
Examples:
| version | value |
| 2.0.0 | equal |
| 2.1.0 | greater |
| 1.9.0 | lesser |
| 2.0.0-alpha | lesser |
| 2.0.0.0 | invalid |

Scenario Outline: Semantic version operator semantic comparision
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>
Examples:
| version | value |
| 3.0.1 | minor |
| 3.1.0 | major |
| 4.0.0 | none |
Then the resolved float value should be 0.0
1 change: 1 addition & 0 deletions sync/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ ENTRYPOINT ["sh", "wrapper.sh", "./sync", "start", \
"-f", "testing-flags.json", \
"-f", "changing-flag.json", \
"-f", "custom-ops.json", \
"-f", "evaluator-refs.json", \
"-f", "zero-flags.json"]

0 comments on commit 5069501

Please sign in to comment.