Coverage Report

Created: 2024-09-19 09:45

/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
11
MockAsyncClient::MockAsyncClient() {
11
11
  async_request_ = std::make_unique<testing::NiceMock<Grpc::MockAsyncRequest>>();
12
11
  ON_CALL(*this, sendRaw(_, _, _, _, _, _))
13
11
      .WillByDefault(Invoke([this](absl::string_view, absl::string_view, Buffer::InstancePtr&&,
14
11
                                   RawAsyncRequestCallbacks&, Tracing::Span&,
15
11
                                   const Http::AsyncClient::RequestOptions&) {
16
1
        send_count_++;
17
1
        return async_request_.get();
18
1
      }));
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
11
  EXPECT_CALL(*this, destination())
23
11
      .Times(testing::AnyNumber())
24
11
      .WillRepeatedly(Return(absl::string_view("unspecified_mock_destination")));
25
11
}
26
11
MockAsyncClient::~MockAsyncClient() = default;
27
28
13
MockAsyncRequest::MockAsyncRequest() = default;
29
13
MockAsyncRequest::~MockAsyncRequest() = default;
30
31
0
MockAsyncStream::MockAsyncStream() = default;
32
0
MockAsyncStream::~MockAsyncStream() = default;
33
34
10
MockAsyncClientFactory::MockAsyncClientFactory() {
35
10
  ON_CALL(*this, createUncachedRawAsyncClient()).WillByDefault(Invoke([] {
36
5
    return std::make_unique<testing::NiceMock<Grpc::MockAsyncClient>>();
37
5
  }));
38
10
}
39
10
MockAsyncClientFactory::~MockAsyncClientFactory() = default;
40
41
27.9k
MockAsyncClientManager::MockAsyncClientManager() {
42
27.9k
  ON_CALL(*this, getOrCreateRawAsyncClient(_, _, _)).WillByDefault(Return(nullptr));
43
27.9k
  ON_CALL(*this, factoryForGrpcService(_, _, _))
44
27.9k
      .WillByDefault(Invoke([](const envoy::config::core::v3::GrpcService&, Stats::Scope&, bool) {
45
5
        return std::make_unique<testing::NiceMock<Grpc::MockAsyncClientFactory>>();
46
5
      }));
47
27.9k
}
48
49
27.9k
MockAsyncClientManager::~MockAsyncClientManager() = default;
50
51
} // namespace Grpc
52
} // namespace Envoy