Skip to content

feat: flagd json eval suite #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 11, 2023
Merged

feat: flagd json eval suite #328

merged 4 commits into from
Sep 11, 2023

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Sep 11, 2023

This PR:

Here is a PR in flagd using this suite: open-feature/flagd#898

@toddbaert toddbaert requested a review from a team as a code owner September 11, 2023 14:03
@toddbaert toddbaert force-pushed the chore/json-eval-tests branch from 9766ff2 to e51604c Compare September 11, 2023 14:03
@@ -614,6 +612,81 @@ func aStringFlagWithKeyIsEvaluatedAsAnIntegerWithDetailsAndADefaultValue(
}), nil
}

func booleanEvaluationDetails(ctx context.Context) (openfeature.BooleanEvaluationDetails, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions were previously used by 2 suties (caching and evaluation). Now they are just used by one so I've moved/renamed them accordingly.

@@ -655,35 +728,6 @@ func theReasonShouldIndicateAnErrorAndTheErrorCodeShouldIndicateATypeMismatchWit
return nil
}

func aProviderIsRegisteredWithCacheDisabled(ctx context.Context) (context.Context, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commonized this initialization method.

Comment on lines +33 to +36
func initializeFlagdJsonScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^a flagd provider is set$`, aFlagdProviderIsSet)
ctx.Step(`^a string flag with key "([^"]*)" is evaluated with default value "([^"]*)"$`, aFlagdStringFlagWithKeyIsEvaluatedWithDefaultValue)
ctx.Step(`^a context containing a key "([^"]*)", with value "([^"]*)"$`, aContextContainingAKeyWithValue)
ctx.Step(`^a context containing a nested property with outer key "([^"]*)" and inner key "([^"]*)", with value "([^"]*)"$`, aContextContainingANestedPropertyWithOuterKeyAndInnerKeyWithValue)
ctx.Step(`^the returned value should be "([^"]*)"$`, theReturnedValueShouldBe)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire gherkin test suite here is captured by these 4 tests, which are run "matrix style" with the table values.


return got, nil
}
func aFlagdProviderIsSet(ctx context.Context) (context.Context, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common init method, used by both suites.

@toddbaert toddbaert force-pushed the chore/json-eval-tests branch from e51604c to fd58f0b Compare September 11, 2023 14:08
@toddbaert toddbaert force-pushed the chore/json-eval-tests branch from fd58f0b to 0f78059 Compare September 11, 2023 14:13
Copy link
Contributor

@bacherfl bacherfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved with an optional suggestion

@toddbaert toddbaert requested a review from mowies September 11, 2023 16:00
toddbaert and others added 2 commits September 11, 2023 12:03
Co-authored-by: Florian Bacher <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Florian Bacher <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
@toddbaert toddbaert merged commit d36f0c5 into main Sep 11, 2023
toddbaert added a commit to open-feature/flagd that referenced this pull request Sep 13, 2023
Uses test suite defined
[here](https://github.com/open-feature/flagd-testbed/blob/main/gherkin/flagd-json-evaluator.feature)
to validate json evaluator behavior end-to-end, by using the test suite
added [here](open-feature/go-sdk-contrib#328).

---------

Signed-off-by: Todd Baert <[email protected]>
liran2000 pushed a commit to liran2000/go-sdk-contrib that referenced this pull request Oct 4, 2023
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Florian Bacher <[email protected]>
Signed-off-by: liran2000 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants