Unref errors in test

pull/18586/head
Yash Tibrewal 6 years ago
parent b7f32af1d0
commit 960864736b
  1. 2
      src/core/ext/filters/client_channel/service_config.cc
  2. 2
      src/core/ext/filters/client_channel/service_config.h
  3. 9
      test/core/client_channel/service_config_test.cc

@ -342,7 +342,7 @@ ServiceConfig::GetMethodServiceConfigObjectsVector(const grpc_slice& path) {
return value;
}
int ServiceConfig::RegisterParser(UniquePtr<ServiceConfigParser> parser) {
size_t ServiceConfig::RegisterParser(UniquePtr<ServiceConfigParser> parser) {
registered_parsers->push_back(std::move(parser));
return registered_parsers->size() - 1;
}

@ -150,7 +150,7 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
/// registered parser. Each parser is responsible for reading the service
/// config json and returning a parsed object. This parsed object can later be
/// retrieved using the same index that was returned at registration time.
static int RegisterParser(UniquePtr<ServiceConfigParser> parser);
static size_t RegisterParser(UniquePtr<ServiceConfigParser> parser);
static void Init();

@ -154,6 +154,7 @@ TEST_F(ServiceConfigTest, ErrorCheck1) {
ASSERT_TRUE(error != GRPC_ERROR_NONE);
EXPECT_TRUE(strstr(grpc_error_string(error),
"failed to parse JSON for service config") != nullptr);
GRPC_ERROR_UNREF(error);
}
TEST_F(ServiceConfigTest, BasicTest1) {
@ -170,6 +171,7 @@ TEST_F(ServiceConfigTest, ErrorNoNames) {
gpr_log(GPR_ERROR, "%s", grpc_error_string(error));
ASSERT_TRUE(error != GRPC_ERROR_NONE);
EXPECT_TRUE(strstr(grpc_error_string(error), "No names found") != nullptr);
GRPC_ERROR_UNREF(error);
}
TEST_F(ServiceConfigTest, ErrorNoNamesWithMultipleMethodConfigs) {
@ -180,6 +182,7 @@ TEST_F(ServiceConfigTest, ErrorNoNamesWithMultipleMethodConfigs) {
gpr_log(GPR_ERROR, "%s", grpc_error_string(error));
ASSERT_TRUE(error != GRPC_ERROR_NONE);
EXPECT_TRUE(strstr(grpc_error_string(error), "No names found") != nullptr);
GRPC_ERROR_UNREF(error);
}
TEST_F(ServiceConfigTest, ValidMethodConfig) {
@ -223,6 +226,7 @@ TEST_F(ServiceConfigTest, Parser1ErrorInvalidType) {
std::smatch match;
std::string s(grpc_error_string(error));
EXPECT_TRUE(std::regex_search(s, match, e));
GRPC_ERROR_UNREF(error);
}
TEST_F(ServiceConfigTest, Parser1ErrorInvalidValue) {
@ -238,6 +242,7 @@ TEST_F(ServiceConfigTest, Parser1ErrorInvalidValue) {
std::smatch match;
std::string s(grpc_error_string(error));
EXPECT_TRUE(std::regex_search(s, match, e));
GRPC_ERROR_UNREF(error);
}
TEST_F(ServiceConfigTest, Parser2BasicTest) {
@ -271,6 +276,7 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidType) {
std::smatch match;
std::string s(grpc_error_string(error));
EXPECT_TRUE(std::regex_search(s, match, e));
GRPC_ERROR_UNREF(error);
}
TEST_F(ServiceConfigTest, Parser2ErrorInvalidValue) {
@ -289,6 +295,7 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidValue) {
std::smatch match;
std::string s(grpc_error_string(error));
EXPECT_TRUE(std::regex_search(s, match, e));
GRPC_ERROR_UNREF(error);
}
// Test parsing with ErrorParsers which always add errors
@ -318,6 +325,7 @@ TEST_F(ErroredParsersScopingTest, GlobalParams) {
std::smatch match;
std::string s(grpc_error_string(error));
EXPECT_TRUE(std::regex_search(s, match, e));
GRPC_ERROR_UNREF(error);
}
TEST_F(ErroredParsersScopingTest, MethodParams) {
@ -341,6 +349,7 @@ TEST_F(ErroredParsersScopingTest, MethodParams) {
std::smatch match;
std::string s(grpc_error_string(error));
EXPECT_TRUE(std::regex_search(s, match, e));
GRPC_ERROR_UNREF(error);
}
} // namespace testing

Loading…
Cancel
Save