#include "worker.h" #include #include "gmock/gmock.h" #include "gtest/gtest.h" namespace Envoy { namespace Server { using ::testing::_; using ::testing::Invoke; MockWorker::MockWorker() { ON_CALL(*this, addListener(_, _, _)) .WillByDefault( Invoke([this](absl::optional overridden_listener, Network::ListenerConfig& config, AddListenerCompletion completion) -> void { UNREFERENCED_PARAMETER(overridden_listener); config.listenSocketFactory().getListenSocket(); EXPECT_EQ(nullptr, add_listener_completion_); add_listener_completion_ = completion; })); ON_CALL(*this, removeListener(_, _)) .WillByDefault( Invoke([this](Network::ListenerConfig&, std::function completion) -> void { EXPECT_EQ(nullptr, remove_listener_completion_); remove_listener_completion_ = completion; })); ON_CALL(*this, stopListener(_, _)) .WillByDefault(Invoke([](Network::ListenerConfig&, std::function completion) -> void { if (completion != nullptr) { completion(); } })); ON_CALL(*this, removeFilterChains(_, _, _)) .WillByDefault(Invoke([this](uint64_t, const std::list&, std::function completion) -> void { EXPECT_EQ(nullptr, remove_filter_chains_completion_); remove_filter_chains_completion_ = completion; })); } MockWorker::~MockWorker() = default; } // namespace Server } // namespace Envoy