-
Notifications
You must be signed in to change notification settings - Fork 11
Unittests for inherited callbacks and configuration validator in updater.h #111
Conversation
test/updater_unittest.cc
Outdated
| return updater.ValidateConfiguration(); | ||
| } | ||
|
|
||
| void UpdateMetadataCallback(MetadataUpdater::ResourceMetadata& result) { |
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.
MetadataUpdater::ResourceMetadata&&.
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.
test/updater_unittest.cc
Outdated
| updater.UpdateMetadataCallback(std::move(result)); | ||
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { |
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.
const MetadataUpdater::ResourceMetadata&.
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.
test/updater_unittest.cc
Outdated
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { | ||
| updater.UpdateResourceCallback(std::move(result)); |
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.
No need to std::move — UpdateResourceCallback takes a const reference.
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.
test/updater_unittest.cc
Outdated
| MetadataStore::Metadata::IGNORED() | ||
| ); | ||
| UpdateResourceCallback(metadata); | ||
| EXPECT_EQ(MonitoredResource("test_resource", {}), store.LookupResource("")); |
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.
I know it fits on one line, but for consistency, let's put the store.LookupResource() call on the next line.
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.
dhrupadb
left a comment
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.
PTAL
test/updater_unittest.cc
Outdated
| return updater.ValidateConfiguration(); | ||
| } | ||
|
|
||
| void UpdateMetadataCallback(MetadataUpdater::ResourceMetadata& result) { |
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.
test/updater_unittest.cc
Outdated
| updater.UpdateMetadataCallback(std::move(result)); | ||
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { |
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.
test/updater_unittest.cc
Outdated
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { | ||
| updater.UpdateResourceCallback(std::move(result)); |
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.
test/updater_unittest.cc
Outdated
| MetadataStore::Metadata::IGNORED() | ||
| ); | ||
| UpdateResourceCallback(metadata); | ||
| EXPECT_EQ(MonitoredResource("test_resource", {}), store.LookupResource("")); |
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.
src/store.h
Outdated
| private: | ||
| friend class MetadataReporter; | ||
| friend class MetadataStoreTest; | ||
| friend class UpdaterTest; |
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 just make GetMetadataMap public instead.
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.
test/updater_unittest.cc
Outdated
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { | ||
| EXPECT_TRUE(ValidateConfiguration()); |
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.
Should we also check that PollingMetadataUpdater::ValidateConfiguration fails when the period is negative?
You would have to pull out the variables from the fixture and make the accessor function take an updater object instead, i.e.:
static bool ValidateConfiguration(const MetadataUpdater& updater) {
return updater.ValidateConfiguration();
}
static void UpdateMetadataCallback(
MetadataUpdater* updater, MetadataUpdater::ResourceMetadata&& result) {
updater->UpdateMetadataCallback(std::move(result));
}
static void UpdateResourceCallback(
MetadataUpdater* updater,
const MetadataUpdater::ResourceMetadata& result) {
updater->UpdateResourceCallback(result);
}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.
dhrupadb
left a comment
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.
PTAL
src/store.h
Outdated
| private: | ||
| friend class MetadataReporter; | ||
| friend class MetadataStoreTest; | ||
| friend class UpdaterTest; |
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.
test/updater_unittest.cc
Outdated
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { | ||
| EXPECT_TRUE(ValidateConfiguration()); |
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.
src/store.h
Outdated
|
|
||
| MetadataStore(const Configuration& config); | ||
|
|
||
| // Returns a copy of the map containing the mapping from monitored |
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.
Just Returns a copy of the mapping from ... is good enough.
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.
test/updater_unittest.cc
Outdated
|
|
||
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { |
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 give this a better name, e.g., OneMinutePollingIntervalIsValid?
Can you also add a ZeroPollingIntervalIsValid test?
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.
test/updater_unittest.cc
Outdated
| EXPECT_TRUE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdaterWithInvalidPollingIntervalTest) { |
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.
NegativePollingIntervalIsInvalid?
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.
test/updater_unittest.cc
Outdated
| EXPECT_FALSE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdateMetadataCallbackTest) { |
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.
The Test suffix in all of these test names is superfluous. Let's get rid of it.
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.
dhrupadb
left a comment
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.
PTAL
src/store.h
Outdated
|
|
||
| MetadataStore(const Configuration& config); | ||
|
|
||
| // Returns a copy of the map containing the mapping from monitored |
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.
test/updater_unittest.cc
Outdated
|
|
||
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { |
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.
test/updater_unittest.cc
Outdated
| EXPECT_TRUE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdaterWithInvalidPollingIntervalTest) { |
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.
test/updater_unittest.cc
Outdated
| EXPECT_FALSE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdateMetadataCallbackTest) { |
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.
igorpeshansky
left a comment
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.
A minor comment nit.
src/store.h
Outdated
|
|
||
| MetadataStore(const Configuration& config); | ||
|
|
||
| // Returns a copy of the mapping from monitored resources to metadata |
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.
from a monitored resource to — otherwise one is plural and one is singular.
Also the metadata.
So:
// Returns a copy of the mapping from a monitored resource to the
// metadata associated with that resource.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.
dhrupadb
left a comment
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.
PTAL
src/store.h
Outdated
|
|
||
| MetadataStore(const Configuration& config); | ||
|
|
||
| // Returns a copy of the mapping from monitored resources to metadata |
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.
igorpeshansky
left a comment
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.
LGTM ![]()
bmoyles0117
left a comment
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.
LGTM
No description provided.