userver: userver/ugrpc/tests/service_fixtures.hpp Source File
Loading...
Searching...
No Matches
service_fixtures.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/ugrpc/tests/service_fixtures.hpp
4/// @brief gtest fixtures for testing ugrpc service implementations. Requires
5/// linking to `userver::grpc-utest`.
6
7#include <userver/utest/utest.hpp>
8#include <userver/utils/statistics/labels.hpp>
9#include <userver/utils/statistics/testing.hpp>
10
11#include <userver/ugrpc/tests/service.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace ugrpc::tests {
16
17/// @see @ref ugrpc::tests::ServiceBase
18// NOLINTNEXTLINE(fuchsia-multiple-inheritance)
19class ServiceFixtureBase : protected ServiceBase, public ::testing::Test {
20 protected:
21 /// @returns the statistics of the server and clients.
22 utils::statistics::Snapshot GetStatistics(
23 std::string prefix,
24 std::vector<utils::statistics::Label> require_labels = {});
25};
26
27/// @see @ref ugrpc::tests::Service
28template <typename GrpcService>
29// NOLINTNEXTLINE(fuchsia-multiple-inheritance)
30class ServiceFixture : protected Service<GrpcService>, public ::testing::Test {
31 protected:
32 using Service<GrpcService>::Service;
33
34 /// @returns the statistics of the server and clients.
35 utils::statistics::Snapshot GetStatistics(
36 std::string prefix,
37 std::vector<utils::statistics::Label> require_labels = {}) {
38 return utils::statistics::Snapshot{this->GetStatisticsStorage(),
39 std::move(prefix),
40 std::move(require_labels)};
41 }
42};
43
44} // namespace ugrpc::tests
45
46USERVER_NAMESPACE_END