-
Notifications
You must be signed in to change notification settings - Fork 2
Add unit-tests for "noop_provider". #37
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a14099c
Add unit-tests for "noop_provider".
NeaguGeorgiana23 5d88692
Fix comments.
NeaguGeorgiana23 1f40da9
Fix comments.
NeaguGeorgiana23 0bcc8d4
Add unit-tests for "noop_provider".
NeaguGeorgiana23 de99606
Fix comments.
NeaguGeorgiana23 a27b4ee
Fix comments.
NeaguGeorgiana23 83e8fbd
Update tests to include "Init()" and "Shutdown()".
NeaguGeorgiana23 d3e9119
Merge branch 'noop_provider_test' of https://github.com/open-feature/…
NeaguGeorgiana23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #include "openfeature/noop_provider.h" | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "absl/status/status.h" | ||
|
|
||
| using namespace openfeature; | ||
|
|
||
| class NoopProviderTest : public ::testing::Test { | ||
| protected: | ||
| NoopProvider provider; | ||
|
NeaguGeorgiana23 marked this conversation as resolved.
|
||
| EvaluationContext ctx; | ||
|
NeaguGeorgiana23 marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| // Test to verify the metadata returned by the provider. | ||
| TEST_F(NoopProviderTest, ShouldReturnProviderNameForMetadata) { | ||
| const Metadata metadata = provider.GetMetadata(); | ||
|
NeaguGeorgiana23 marked this conversation as resolved.
|
||
| EXPECT_EQ(metadata.name, "Noop Provider"); | ||
| } | ||
|
|
||
| // Test to verify the Init method returns an OK status. | ||
| TEST_F(NoopProviderTest, InitShouldReturnOkStatus) { | ||
| const absl::Status status = provider.Init(ctx); | ||
| EXPECT_EQ(status, absl::OkStatus()); | ||
| } | ||
|
|
||
| // Test to verify the Shutdown method returns an OK status. | ||
| TEST_F(NoopProviderTest, ShutdownShouldReturnOkStatus) { | ||
| const absl::Status status = provider.Shutdown(); | ||
| EXPECT_EQ(status, absl::OkStatus()); | ||
| } | ||
|
|
||
| class NoopProviderBooleanTest : public NoopProviderTest, | ||
| public ::testing::WithParamInterface<bool> {}; | ||
|
|
||
| // Test to verify the boolean evaluation returns the default value. | ||
| TEST_P(NoopProviderBooleanTest, BooleanEvaluationShouldReturnDefaultValue) { | ||
| const bool defaultValue = GetParam(); | ||
|
|
||
| const std::unique_ptr<BoolResolutionDetails> details = | ||
| provider.GetBooleanEvaluation("my-bool-flag", defaultValue, ctx); | ||
|
|
||
| EXPECT_EQ(details->GetValue(), defaultValue); | ||
| EXPECT_EQ(details->GetReason(), Reason::kDefault); | ||
| EXPECT_EQ(details->GetVariant(), "default-variant"); | ||
| EXPECT_FALSE(details->GetErrorCode().has_value()); | ||
| ASSERT_TRUE(details->GetErrorMessage().has_value()); | ||
| EXPECT_TRUE(details->GetErrorMessage()->empty()); | ||
| } | ||
|
|
||
| INSTANTIATE_TEST_SUITE_P(BooleanDefaultValues, NoopProviderBooleanTest, | ||
| testing::Values(true, false)); | ||
|
|
||
|
NeaguGeorgiana23 marked this conversation as resolved.
|
||
| // Main function to initialize and run all tests. | ||
| int main(int argc, char** argv) { | ||
| testing::InitGoogleTest(&argc, argv); | ||
| return RUN_ALL_TESTS(); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.