Coverage Report

Created: 2024-09-19 09:45

/proc/self/cwd/test/mocks/upstream/host_set.cc
Line
Count
Source (jump to first uncovered line)
1
#include "host_set.h"
2
3
#include "gmock/gmock.h"
4
#include "gtest/gtest.h"
5
6
namespace Envoy {
7
namespace Upstream {
8
using ::testing::Invoke;
9
using ::testing::Return;
10
using ::testing::ReturnRef;
11
MockHostSet::MockHostSet(uint32_t priority, uint32_t overprovisioning_factor)
12
52.6k
    : priority_(priority), overprovisioning_factor_(overprovisioning_factor) {
13
52.6k
  ON_CALL(*this, priority()).WillByDefault(Return(priority_));
14
52.6k
  ON_CALL(*this, hosts()).WillByDefault(ReturnRef(hosts_));
15
52.6k
  ON_CALL(*this, hostsPtr()).WillByDefault(Invoke([this]() {
16
1.53k
    return std::make_shared<HostVector>(hosts_);
17
1.53k
  }));
18
52.6k
  ON_CALL(*this, healthyHosts()).WillByDefault(ReturnRef(healthy_hosts_));
19
52.6k
  ON_CALL(*this, healthyHostsPtr()).WillByDefault(Invoke([this]() {
20
1.53k
    return std::make_shared<HealthyHostVector>(healthy_hosts_);
21
1.53k
  }));
22
52.6k
  ON_CALL(*this, degradedHosts()).WillByDefault(ReturnRef(degraded_hosts_));
23
52.6k
  ON_CALL(*this, degradedHostsPtr()).WillByDefault(Invoke([this]() {
24
1.53k
    return std::make_shared<DegradedHostVector>(degraded_hosts_);
25
1.53k
  }));
26
52.6k
  ON_CALL(*this, excludedHosts()).WillByDefault(ReturnRef(excluded_hosts_));
27
52.6k
  ON_CALL(*this, excludedHostsPtr()).WillByDefault(Invoke([this]() {
28
1.53k
    return std::make_shared<ExcludedHostVector>(excluded_hosts_);
29
1.53k
  }));
30
52.6k
  ON_CALL(*this, hostsPerLocality()).WillByDefault(Invoke([this]() -> const HostsPerLocality& {
31
0
    return *hosts_per_locality_;
32
0
  }));
33
52.6k
  ON_CALL(*this, hostsPerLocalityPtr()).WillByDefault(Return(hosts_per_locality_));
34
52.6k
  ON_CALL(*this, healthyHostsPerLocality())
35
52.6k
      .WillByDefault(
36
64.2k
          Invoke([this]() -> const HostsPerLocality& { return *healthy_hosts_per_locality_; }));
37
52.6k
  ON_CALL(*this, healthyHostsPerLocalityPtr()).WillByDefault(Return(healthy_hosts_per_locality_));
38
52.6k
  ON_CALL(*this, degradedHostsPerLocality())
39
52.6k
      .WillByDefault(
40
61.3k
          Invoke([this]() -> const HostsPerLocality& { return *degraded_hosts_per_locality_; }));
41
52.6k
  ON_CALL(*this, degradedHostsPerLocalityPtr()).WillByDefault(Return(degraded_hosts_per_locality_));
42
52.6k
  ON_CALL(*this, excludedHostsPerLocality())
43
52.6k
      .WillByDefault(
44
52.6k
          Invoke([this]() -> const HostsPerLocality& { return *excluded_hosts_per_locality_; }));
45
52.6k
  ON_CALL(*this, excludedHostsPerLocalityPtr()).WillByDefault(Return(excluded_hosts_per_locality_));
46
52.6k
  ON_CALL(*this, localityWeights()).WillByDefault(Invoke([this]() -> LocalityWeightsConstSharedPtr {
47
0
    return locality_weights_;
48
0
  }));
49
52.6k
}
50
51
52.6k
MockHostSet::~MockHostSet() = default;
52
53
} // namespace Upstream
54
55
} // namespace Envoy