Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/test/mocks/grpc/mocks.cc
Line
Count
Source (jump to first uncovered line)
1
#include "mocks.h"
2
3
#include "test/mocks/http/mocks.h"
4
5
using testing::Return;
6
7
namespace Envoy {
8
namespace Grpc {
9
10
15
MockAsyncClient::MockAsyncClient() {
11
15
  async_request_ = std::make_unique<testing::NiceMock<Grpc::MockAsyncRequest>>();
12
15
  ON_CALL(*this, sendRaw(_, _, _, _, _, _))
13
15
      .WillByDefault(Invoke([this](absl::string_view, absl::string_view, Buffer::InstancePtr&&,
14
15
                                   RawAsyncRequestCallbacks&, Tracing::Span&,
15
15
                                   const Http::AsyncClient::RequestOptions&) {
16
3
        send_count_++;
17
3
        return async_request_.get();
18
3
      }));
19
20
  // Because this method is used in debug logs, coverage and non-coverage builds have different
21
  // expectations, so add this to prevent failures due to "uninteresting mock function call".
22
15
  EXPECT_CALL(*this, destination())
23
15
      .Times(testing::AnyNumber())
24
15
      .WillRepeatedly(Return(absl::string_view("unspecified_mock_destination")));
25
15
}
26
15
MockAsyncClient::~MockAsyncClient() = default;
27
28
16
MockAsyncRequest::MockAsyncRequest() = default;
29
16
MockAsyncRequest::~MockAsyncRequest() = default;
30
31
0
MockAsyncStream::MockAsyncStream() = default;
32
0
MockAsyncStream::~MockAsyncStream() = default;
33
34
15
MockAsyncClientFactory::MockAsyncClientFactory() {
35
15
  ON_CALL(*this, createUncachedRawAsyncClient()).WillByDefault(Invoke([] {
36
5
    return std::make_unique<testing::NiceMock<Grpc::MockAsyncClient>>();
37
5
  }));
38
15
}
39
15
MockAsyncClientFactory::~MockAsyncClientFactory() = default;
40
41
31.4k
MockAsyncClientManager::MockAsyncClientManager() {
42
31.4k
  ON_CALL(*this, factoryForGrpcService(_, _, _))
43
31.4k
      .WillByDefault(Invoke([](const envoy::config::core::v3::GrpcService&, Stats::Scope&, bool) {
44
5
        return std::make_unique<testing::NiceMock<Grpc::MockAsyncClientFactory>>();
45
5
      }));
46
31.4k
}
47
48
31.4k
MockAsyncClientManager::~MockAsyncClientManager() = default;
49
50
} // namespace Grpc
51
} // namespace Envoy