Skip to content

Commit

Permalink
test: add a common test base class (envoyproxy#5811)
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Marantz <[email protected]>
  • Loading branch information
jmarantz authored and mattklein123 committed Feb 4, 2019
1 parent f54d222 commit cb3ac04
Show file tree
Hide file tree
Showing 418 changed files with 795 additions and 824 deletions.
1 change: 1 addition & 0 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def envoy_cc_test_library(
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] + [
envoy_external_dep_path("googletest"),
repository + "//test/test_common:printers_includes",
repository + "//test/test_common:test_base",
],
tags = tags,
alwayslink = 1,
Expand Down
2 changes: 1 addition & 1 deletion test/common/access_log/access_log_formatter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "test/mocks/stream_info/mocks.h"
#include "test/mocks/upstream/mocks.h"
#include "test/test_common/printers.h"
#include "test/test_common/test_base.h"
#include "test/test_common/utility.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
using testing::Const;
Expand Down
4 changes: 2 additions & 2 deletions test/common/access_log/access_log_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include "test/mocks/server/mocks.h"
#include "test/mocks/upstream/mocks.h"
#include "test/test_common/printers.h"
#include "test/test_common/test_base.h"
#include "test/test_common/utility.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
using testing::NiceMock;
Expand All @@ -48,7 +48,7 @@ envoy::config::filter::accesslog::v2::AccessLog parseAccessLogFromV2Yaml(const s
return access_log;
}

class AccessLogImplTest : public testing::Test {
class AccessLogImplTest : public TestBase {
public:
AccessLogImplTest() : file_(new Filesystem::MockFile()) {
ON_CALL(context_, runtime()).WillByDefault(ReturnRef(runtime_));
Expand Down
2 changes: 1 addition & 1 deletion test/common/access_log/access_log_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include "test/mocks/api/mocks.h"
#include "test/mocks/event/mocks.h"
#include "test/mocks/filesystem/mocks.h"
#include "test/test_common/test_base.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
using testing::Return;
Expand Down
3 changes: 1 addition & 2 deletions test/common/buffer/buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

#include "test/common/buffer/utility.h"
#include "test/test_common/printers.h"
#include "test/test_common/test_base.h"
#include "test/test_common/utility.h"

#include "gtest/gtest.h"

namespace Envoy {
namespace Buffer {
namespace {
Expand Down
4 changes: 2 additions & 2 deletions test/common/buffer/owned_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include "common/buffer/buffer_impl.h"

#include "test/mocks/api/mocks.h"
#include "test/test_common/test_base.h"
#include "test/test_common/threadsafe_singleton_injector.h"

#include "absl/strings/str_cat.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
using testing::Return;
Expand All @@ -15,7 +15,7 @@ namespace Envoy {
namespace Buffer {
namespace {

class OwnedImplTest : public testing::Test {
class OwnedImplTest : public TestBase {
public:
OwnedImplTest() {}

Expand Down
2 changes: 1 addition & 1 deletion test/common/buffer/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "common/buffer/buffer_impl.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
namespace Buffer {
Expand Down
4 changes: 2 additions & 2 deletions test/common/buffer/watermark_buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#include "common/buffer/buffer_impl.h"
#include "common/buffer/watermark_buffer.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
namespace Buffer {
namespace {

const char TEN_BYTES[] = "0123456789";

class WatermarkBufferTest : public testing::Test {
class WatermarkBufferTest : public TestBase {
public:
WatermarkBufferTest() { buffer_.setWatermarks(5, 10); }

Expand Down
4 changes: 2 additions & 2 deletions test/common/buffer/zero_copy_input_stream_test.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "common/buffer/buffer_impl.h"
#include "common/buffer/zero_copy_input_stream_impl.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
namespace Buffer {
namespace {

class ZeroCopyInputStreamTest : public testing::Test {
class ZeroCopyInputStreamTest : public TestBase {
public:
ZeroCopyInputStreamTest() {
Buffer::OwnedImpl buffer{"abcd"};
Expand Down
3 changes: 1 addition & 2 deletions test/common/common/assert_test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "common/common/assert.h"

#include "test/test_common/logging.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {

Expand Down
3 changes: 1 addition & 2 deletions test/common/common/backoff_strategy_test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "common/common/backoff_strategy.h"

#include "test/mocks/runtime/mocks.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

using testing::NiceMock;
using testing::Return;
Expand Down
3 changes: 1 addition & 2 deletions test/common/common/base64_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include "common/common/base64.h"

#include "test/test_common/printers.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
TEST(Base64Test, EmptyBufferEncode) {
Expand Down
5 changes: 3 additions & 2 deletions test/common/common/block_memory_hash_set_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#include "common/common/hash.h"
#include "common/stats/stats_options_impl.h"

#include "test/test_common/test_base.h"

#include "absl/strings/string_view.h"
#include "gtest/gtest.h"

namespace Envoy {

// Tests BlockMemoryHashSet.
class BlockMemoryHashSetTest : public testing::Test {
class BlockMemoryHashSetTest : public TestBase {
protected:
// TestValue that doesn't define a hash.
struct TestValueBase {
Expand Down
4 changes: 3 additions & 1 deletion test/common/common/callback_impl_test.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include "common/common/callback_impl.h"

#include "test/test_common/test_base.h"

#include "gmock/gmock.h"

using testing::InSequence;

namespace Envoy {
namespace Common {

class CallbackManagerTest : public testing::Test {
class CallbackManagerTest : public TestBase {
public:
MOCK_METHOD1(called, void(int arg));
};
Expand Down
2 changes: 1 addition & 1 deletion test/common/common/cleanup_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common/common/cleanup.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {

Expand Down
3 changes: 2 additions & 1 deletion test/common/common/fmt_test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "common/common/fmt.h"
#include "common/common/logger.h"

#include "test/test_common/test_base.h"

#include "absl/strings/string_view.h"
#include "gtest/gtest.h"

namespace Envoy {

Expand Down
2 changes: 1 addition & 1 deletion test/common/common/hash_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common/common/hash.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
TEST(Hash, xxHash) {
Expand Down
2 changes: 1 addition & 1 deletion test/common/common/hex_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "common/common/hex.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
TEST(Hex, SimpleEncode) {
Expand Down
4 changes: 2 additions & 2 deletions test/common/common/lock_guard_test.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "common/common/lock_guard.h"
#include "common/common/thread.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
namespace Thread {

class ThreadTest : public testing::Test {
class ThreadTest : public TestBase {
protected:
ThreadTest() : a_(0), b_(0) {}
int a_ GUARDED_BY(a_mutex_);
Expand Down
2 changes: 1 addition & 1 deletion test/common/common/log_macros_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include "test/mocks/http/mocks.h"
#include "test/mocks/network/mocks.h"
#include "test/test_common/test_base.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace Envoy {

Expand Down
2 changes: 1 addition & 1 deletion test/common/common/matchers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "common/config/metadata.h"
#include "common/protobuf/protobuf.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
namespace Matcher {
Expand Down
4 changes: 2 additions & 2 deletions test/common/common/mutex_tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "common/common/mutex_tracer_impl.h"

#include "test/test_common/contention.h"
#include "test/test_common/test_base.h"

#include "absl/synchronization/mutex.h"
#include "gtest/gtest.h"

namespace Envoy {

class MutexTracerTest : public testing::Test {
class MutexTracerTest : public TestBase {
protected:
void SetUp() override { tracer_.reset(); }

Expand Down
2 changes: 1 addition & 1 deletion test/common/common/perf_annotation_disabled_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "common/common/perf_annotation.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {

Expand Down
4 changes: 2 additions & 2 deletions test/common/common/perf_annotation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

#include "common/common/perf_annotation.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {

class PerfAnnotationTest : public testing::Test {
class PerfAnnotationTest : public TestBase {
protected:
void TearDown() override { PERF_CLEAR(); }
};
Expand Down
2 changes: 1 addition & 1 deletion test/common/common/phantom_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common/common/phantom.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {

Expand Down
3 changes: 2 additions & 1 deletion test/common/common/stack_array_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "common/common/stack_array.h"

#include "test/test_common/test_base.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace Envoy {

Expand Down
2 changes: 1 addition & 1 deletion test/common/common/to_lower_table_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common/common/to_lower_table.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {
TEST(ToLowerTableTest, All) {
Expand Down
5 changes: 2 additions & 3 deletions test/common/common/token_bucket_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
#include "common/common/token_bucket_impl.h"

#include "test/test_common/simulated_time_system.h"

#include "gtest/gtest.h"
#include "test/test_common/test_base.h"

namespace Envoy {

class TokenBucketImplTest : public testing::Test {
class TokenBucketImplTest : public TestBase {
protected:
Event::SimulatedTimeSystem time_system_;
};
Expand Down
2 changes: 1 addition & 1 deletion test/common/common/utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

#include "common/common/utility.h"

#include "test/test_common/test_base.h"
#include "test/test_common/test_time.h"
#include "test/test_common/utility.h"

#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::ContainerEq;

Expand Down
5 changes: 2 additions & 3 deletions test/common/compressor/zlib_compressor_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
#include "common/common/stack_array.h"
#include "common/compressor/zlib_compressor_impl.h"

#include "test/test_common/test_base.h"
#include "test/test_common/utility.h"

#include "gtest/gtest.h"

namespace Envoy {
namespace Compressor {
namespace {

class ZlibCompressorImplTest : public testing::Test {
class ZlibCompressorImplTest : public TestBase {
protected:
void expectValidFlushedBuffer(const Buffer::OwnedImpl& output_buffer) {
uint64_t num_comp_slices = output_buffer.getRawSlices(nullptr, 0);
Expand Down
4 changes: 2 additions & 2 deletions test/common/config/config_provider_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include "test/common/config/dummy_config.pb.h"
#include "test/mocks/server/mocks.h"
#include "test/test_common/simulated_time_system.h"
#include "test/test_common/test_base.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace Envoy {
namespace Config {
Expand Down Expand Up @@ -205,7 +205,7 @@ DummyConfigSubscription::DummyConfigSubscription(
"DummyDS", manager_identifier, config_provider_manager, factory_context.timeSource(),
factory_context.timeSource().systemTime(), factory_context.localInfo()) {}

class ConfigProviderImplTest : public testing::Test {
class ConfigProviderImplTest : public TestBase {
public:
ConfigProviderImplTest() {
EXPECT_CALL(factory_context_.admin_.config_tracker_, add_("dummy", _));
Expand Down
Loading

0 comments on commit cb3ac04

Please sign in to comment.