Loading metricsd/uploader/system_profile_cache.cc +2 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,8 @@ bool SystemProfileCache::Initialize() { } } if (!reader.GetString(metrics::kProductId, &profile_.product_id)) { if (!reader.GetString(metrics::kProductId, &profile_.product_id) || profile_.product_id.empty()) { LOG(ERROR) << "product_id is not set."; return false; } Loading metricsd/uploader/system_profile_cache.h +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ class SystemProfileCache : public SystemProfileSetter { FRIEND_TEST(UploadServiceTest, ReadKeyValueFromFile); FRIEND_TEST(UploadServiceTest, SessionIdIncrementedAtInitialization); FRIEND_TEST(UploadServiceTest, ValuesInConfigFileAreSent); FRIEND_TEST(UploadServiceTest, ProductIdMandatory); // Fetches all informations and populates |profile_| bool Initialize(); Loading metricsd/uploader/upload_service_test.cc +11 −0 Original line number Diff line number Diff line Loading @@ -291,3 +291,14 @@ TEST_F(UploadServiceTest, LogFromTheMetricsLibrary) { EXPECT_EQ(1, sender->send_call_count()); } // The product id must be set for metrics to be uploaded. // If it is not set, the system profile cache should fail to initialize. TEST_F(UploadServiceTest, ProductIdMandatory) { SystemProfileCache cache(true, dir_.path()); ASSERT_FALSE(cache.Initialize()); SetTestingProperty(metrics::kProductId, ""); ASSERT_FALSE(cache.Initialize()); SetTestingProperty(metrics::kProductId, "hello"); ASSERT_TRUE(cache.Initialize()); } Loading
metricsd/uploader/system_profile_cache.cc +2 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,8 @@ bool SystemProfileCache::Initialize() { } } if (!reader.GetString(metrics::kProductId, &profile_.product_id)) { if (!reader.GetString(metrics::kProductId, &profile_.product_id) || profile_.product_id.empty()) { LOG(ERROR) << "product_id is not set."; return false; } Loading
metricsd/uploader/system_profile_cache.h +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ class SystemProfileCache : public SystemProfileSetter { FRIEND_TEST(UploadServiceTest, ReadKeyValueFromFile); FRIEND_TEST(UploadServiceTest, SessionIdIncrementedAtInitialization); FRIEND_TEST(UploadServiceTest, ValuesInConfigFileAreSent); FRIEND_TEST(UploadServiceTest, ProductIdMandatory); // Fetches all informations and populates |profile_| bool Initialize(); Loading
metricsd/uploader/upload_service_test.cc +11 −0 Original line number Diff line number Diff line Loading @@ -291,3 +291,14 @@ TEST_F(UploadServiceTest, LogFromTheMetricsLibrary) { EXPECT_EQ(1, sender->send_call_count()); } // The product id must be set for metrics to be uploaded. // If it is not set, the system profile cache should fail to initialize. TEST_F(UploadServiceTest, ProductIdMandatory) { SystemProfileCache cache(true, dir_.path()); ASSERT_FALSE(cache.Initialize()); SetTestingProperty(metrics::kProductId, ""); ASSERT_FALSE(cache.Initialize()); SetTestingProperty(metrics::kProductId, "hello"); ASSERT_TRUE(cache.Initialize()); }