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.
MetadataUpdater::ResourceMetadata&&.
test/updater_unittest.cc
Outdated
| updater.UpdateMetadataCallback(std::move(result)); | ||
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { |
There was a problem hiding this comment.
const MetadataUpdater::ResourceMetadata&.
test/updater_unittest.cc
Outdated
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { | ||
| updater.UpdateResourceCallback(std::move(result)); |
There was a problem hiding this comment.
No need to std::move — UpdateResourceCallback takes a const reference.
test/updater_unittest.cc
Outdated
| MetadataStore::Metadata::IGNORED() | ||
| ); | ||
| UpdateResourceCallback(metadata); | ||
| EXPECT_EQ(MonitoredResource("test_resource", {}), store.LookupResource("")); |
There was a problem hiding this comment.
I know it fits on one line, but for consistency, let's put the store.LookupResource() call on the next line.
test/updater_unittest.cc
Outdated
| return updater.ValidateConfiguration(); | ||
| } | ||
|
|
||
| void UpdateMetadataCallback(MetadataUpdater::ResourceMetadata& result) { |
test/updater_unittest.cc
Outdated
| updater.UpdateMetadataCallback(std::move(result)); | ||
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { |
test/updater_unittest.cc
Outdated
| } | ||
|
|
||
| void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) { | ||
| updater.UpdateResourceCallback(std::move(result)); |
test/updater_unittest.cc
Outdated
| MetadataStore::Metadata::IGNORED() | ||
| ); | ||
| UpdateResourceCallback(metadata); | ||
| EXPECT_EQ(MonitoredResource("test_resource", {}), store.LookupResource("")); |
src/store.h
Outdated
| private: | ||
| friend class MetadataReporter; | ||
| friend class MetadataStoreTest; | ||
| friend class UpdaterTest; |
There was a problem hiding this comment.
Let's just make GetMetadataMap public instead.
test/updater_unittest.cc
Outdated
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { | ||
| EXPECT_TRUE(ValidateConfiguration()); |
There was a problem hiding this comment.
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);
}
src/store.h
Outdated
| private: | ||
| friend class MetadataReporter; | ||
| friend class MetadataStoreTest; | ||
| friend class UpdaterTest; |
test/updater_unittest.cc
Outdated
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { | ||
| EXPECT_TRUE(ValidateConfiguration()); |
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.
Just Returns a copy of the mapping from ... is good enough.
test/updater_unittest.cc
Outdated
|
|
||
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { |
There was a problem hiding this comment.
Let's give this a better name, e.g., OneMinutePollingIntervalIsValid?
Can you also add a ZeroPollingIntervalIsValid test?
test/updater_unittest.cc
Outdated
| EXPECT_TRUE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdaterWithInvalidPollingIntervalTest) { |
There was a problem hiding this comment.
NegativePollingIntervalIsInvalid?
test/updater_unittest.cc
Outdated
| EXPECT_FALSE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdateMetadataCallbackTest) { |
There was a problem hiding this comment.
The Test suffix in all of these test names is superfluous. Let's get rid of it.
src/store.h
Outdated
|
|
||
| MetadataStore(const Configuration& config); | ||
|
|
||
| // Returns a copy of the map containing the mapping from monitored |
test/updater_unittest.cc
Outdated
|
|
||
| namespace { | ||
|
|
||
| TEST_F(UpdaterTest, ValidateConfiguration) { |
test/updater_unittest.cc
Outdated
| EXPECT_TRUE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdaterWithInvalidPollingIntervalTest) { |
test/updater_unittest.cc
Outdated
| EXPECT_FALSE(ValidateConfiguration(&updater)); | ||
| } | ||
|
|
||
| TEST_F(UpdaterTest, UpdateMetadataCallbackTest) { |
igorpeshansky
left a comment
There was a problem hiding this comment.
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.
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.
src/store.h
Outdated
|
|
||
| MetadataStore(const Configuration& config); | ||
|
|
||
| // Returns a copy of the mapping from monitored resources to metadata |
No description provided.