Skip to content

Commit

Permalink
Add gherkin tests to verify evaluation details in finally hooks (#290)
Browse files Browse the repository at this point in the history
Signed-off-by: christian.lutnik <[email protected]>
  • Loading branch information
chrfwow authored Feb 7, 2025
1 parent 8d6eeb3 commit 95fe981
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion specification/assets/gherkin/evaluation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Flag evaluation
# This test suite contains scenarios to test the flag evaluation API.

Background:
Given a provider is registered
Given a stable provider

# basic evaluation
Scenario: Resolves boolean value
Expand Down
49 changes: 49 additions & 0 deletions specification/assets/gherkin/hooks.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@hooks
Feature: Evaluation details through hooks

# This test suite contains scenarios to test the functionality of hooks.

Background:
Given a stable provider

Scenario: Passes evaluation details to after and finally hooks
Given a client with added hook
And a boolean-flag with key "boolean-flag" and a default value "false"
When the flag was evaluated with details
Then the "before" hook should have been executed
And the "after, finally" hooks should be called with evaluation details
| data_type | key | value |
| string | flag_key | boolean-flag |
| boolean | value | true |
| string | variant | on |
| string | reason | STATIC |
| string | error_code | null |

# errors
Scenario: Flag not found
Given a client with added hook
And a string-flag with key "missing-flag" and a default value "uh-oh"
When the flag was evaluated with details
Then the "before" hook should have been executed
And the "error" hook should have been executed
And the "finally" hooks should be called with evaluation details
| data_type | key | value |
| string | flag_key | missing-flag |
| string | value | uh-oh |
| string | variant | null |
| string | reason | ERROR |
| string | error_code | FLAG_NOT_FOUND |

Scenario: Type error
Given a client with added hook
And a string-flag with key "wrong-flag" and a default value "13"
When the flag was evaluated with details
Then the "before" hook should have been executed
And the "error" hook should have been executed
And the "finally" hooks should be called with evaluation details
| data_type | key | value |
| string | flag_key | wrong-flag |
| integer | value | 13 |
| string | variant | null |
| string | reason | ERROR |
| string | error_code | TYPE_MISMATCH |

0 comments on commit 95fe981

Please sign in to comment.