This repository was archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Unittests for InstanceMonitoredResource and InstanceResourceMetadata #105
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fbcea52
Unittests for InstanceMonitoredResource and InstanceResourceMetadata
dhrupadb 900af04
Address feedback
dhrupadb 90c6f2e
Remove empty config unittest
dhrupadb 4416a59
Address feedback
dhrupadb 334b88f
Address feedback. ResourceMetadata accessors private
dhrupadb a4cf3be
Address feedback
dhrupadb f9f8b4b
Inline comment
dhrupadb ee86ee5
Formatting
dhrupadb c854403
Tiny nit
dhrupadb 03b2733
Update kubernetes_unittest to use new ResourceMetadata API
dhrupadb 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
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
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,45 @@ | ||
| #include "../src/configuration.h" | ||
| #include "../src/environment.h" | ||
| #include "../src/instance.h" | ||
| #include "../src/resource.h" | ||
| #include "../src/updater.h" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace google { | ||
|
|
||
| namespace { | ||
|
|
||
| TEST(InstanceTest, GetInstanceMonitoredResource) { | ||
| Configuration config(std::istringstream( | ||
| "InstanceResourceType: gce_instance\n" | ||
| "InstanceId: 1234567891011\n" | ||
| "InstanceZone: us-east1-b\n" | ||
| )); | ||
| Environment env(config); | ||
| EXPECT_EQ(MonitoredResource("gce_instance", { | ||
| {"instance_id", "1234567891011"}, | ||
| {"zone", "us-east1-b"} | ||
| }), InstanceReader::InstanceResource(env)); | ||
| } | ||
|
|
||
| TEST(InstanceTest, GetInstanceMetatadataQuery) { | ||
| Configuration config(std::istringstream( | ||
| "InstanceResourceType: gce_instance\n" | ||
| "InstanceId: 1234567891011\n" | ||
| "InstanceZone: us-east1-b\n" | ||
| )); | ||
| InstanceReader reader(config); | ||
| const auto result = reader.MetadataQuery(); | ||
| EXPECT_EQ(1, result.size()); | ||
| const MetadataUpdater::ResourceMetadata& rm = result[0]; | ||
| EXPECT_EQ(MonitoredResource("gce_instance", { | ||
| {"instance_id", "1234567891011"}, | ||
| {"zone", "us-east1-b"} | ||
| }), rm.resource()); | ||
| EXPECT_EQ(std::vector<std::string>({"", "1234567891011"}), rm.ids()); | ||
| EXPECT_TRUE(rm.metadata().ignore); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a blank line between this and the first function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.