Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/test/mocks/server/worker.cc
Line
Count
Source (jump to first uncovered line)
1
#include "worker.h"
2
3
#include <string>
4
5
#include "gmock/gmock.h"
6
#include "gtest/gtest.h"
7
8
namespace Envoy {
9
namespace Server {
10
11
using ::testing::_;
12
using ::testing::Invoke;
13
14
0
MockWorker::MockWorker() {
15
0
  ON_CALL(*this, addListener(_, _, _, _))
16
0
      .WillByDefault(Invoke([this](absl::optional<uint64_t> overridden_listener,
17
0
                                   Network::ListenerConfig& config,
18
0
                                   AddListenerCompletion completion, Runtime::Loader&) -> void {
19
0
        UNREFERENCED_PARAMETER(overridden_listener);
20
0
        config.listenSocketFactories()[0]->getListenSocket(0);
21
0
        EXPECT_EQ(nullptr, add_listener_completion_);
22
0
        add_listener_completion_ = completion;
23
0
      }));
24
25
0
  ON_CALL(*this, removeListener(_, _))
26
0
      .WillByDefault(
27
0
          Invoke([this](Network::ListenerConfig&, std::function<void()> completion) -> void {
28
0
            EXPECT_EQ(nullptr, remove_listener_completion_);
29
0
            remove_listener_completion_ = completion;
30
0
          }));
31
32
0
  ON_CALL(*this, stopListener(_, _, _))
33
0
      .WillByDefault(
34
0
          Invoke([](Network::ListenerConfig&, const Network::ExtraShutdownListenerOptions&,
35
0
                    std::function<void()> completion) -> void {
36
0
            if (completion != nullptr) {
37
0
              completion();
38
0
            }
39
0
          }));
40
41
0
  ON_CALL(*this, removeFilterChains(_, _, _))
42
0
      .WillByDefault(Invoke([this](uint64_t, const std::list<const Network::FilterChain*>&,
43
0
                                   std::function<void()> completion) -> void {
44
0
        EXPECT_EQ(nullptr, remove_filter_chains_completion_);
45
0
        remove_filter_chains_completion_ = completion;
46
0
      }));
47
48
0
  ON_CALL(*this, start(_, _))
49
0
      .WillByDefault(Invoke([](GuardDog&, const std::function<void()>& cb) -> void { cb(); }));
50
0
}
51
52
0
MockWorker::~MockWorker() = default;
53
54
} // namespace Server
55
} // namespace Envoy