Skip to content

Commit

Permalink
test: print test parameters meaningfully (#14604)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Konradi <[email protected]>
  • Loading branch information
akonradi authored Jan 14, 2021
1 parent e3bbb5f commit 38a6fe5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/common/config/subscription_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ enum class SubscriptionType {
Filesystem,
};

// NOLINTNEXTLINE(readability-identifier-naming)
void PrintTo(const SubscriptionType sub, std::ostream* os) {
(*os) << ([sub]() -> absl::string_view {
switch (sub) {
case SubscriptionType::Grpc:
return "Grpc";
case SubscriptionType::DeltaGrpc:
return "DeltaGrpc";
case SubscriptionType::Http:
return "Http";
case SubscriptionType::Filesystem:
return "Filesystem";
default:
return "unknown";
}
})();
}

class SubscriptionImplTest : public testing::TestWithParam<SubscriptionType> {
public:
SubscriptionImplTest() : SubscriptionImplTest(std::chrono::milliseconds(0)) {}
Expand Down
16 changes: 16 additions & 0 deletions test/common/upstream/health_checker_impl_test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <chrono>
#include <memory>
#include <ostream>
#include <string>

#include "envoy/config/core/v3/base.pb.h"
Expand Down Expand Up @@ -4285,6 +4286,21 @@ class GrpcHealthCheckerImplTestBase : public Event::TestUsingSimulatedTime,
std::list<uint32_t> codec_index_{};
};

// NOLINTNEXTLINE(readability-identifier-naming)
void PrintTo(const GrpcHealthCheckerImplTestBase::ResponseSpec& spec, std::ostream* os) {
(*os) << "(headers{" << absl::StrJoin(spec.response_headers, ",", absl::PairFormatter(":"))
<< "},";
(*os) << "body{" << absl::StrJoin(spec.body_chunks, ",", [](std::string* out, const auto& spec) {
absl::StrAppend(out, spec.valid ? "valid" : "invalid", ",{",
absl::StrJoin(spec.data, "-",
[](std::string* out, uint8_t byte) {
absl::StrAppend(out, absl::Hex(byte, absl::kZeroPad2));
}),
"}");
}) << "}";
(*os) << "trailers{" << absl::StrJoin(spec.trailers, ",", absl::PairFormatter(":")) << "})";
}

class GrpcHealthCheckerImplTest : public testing::Test, public GrpcHealthCheckerImplTestBase {};

// Test single host check success.
Expand Down

0 comments on commit 38a6fe5

Please sign in to comment.