Content-Length: 536152 | pFad | http://github.com/googleapis/google-cloud-cpp/commit/eb5abbaf5c3732f0f37a1a3ba3bd49956a1eefaf

06 refactor: split `MockRequestIdServiceStub` (#13709) · googleapis/google-cloud-cpp@eb5abba · GitHub
Skip to content

Commit eb5abba

Browse files
authored
refactor: split MockRequestIdServiceStub (#13709)
1 parent af29661 commit eb5abba

File tree

3 files changed

+81
-47
lines changed

3 files changed

+81
-47
lines changed

generator/integration_tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ find_package(GTest CONFIG REQUIRED)
9393

9494
add_library(
9595
google_cloud_cpp_generator_golden_testing # cmake-format: sort
96-
tests/mock_golden_kitchen_sink_stub.h tests/mock_golden_thing_admin_stub.h)
96+
tests/mock_golden_kitchen_sink_stub.h tests/mock_golden_thing_admin_stub.h
97+
tests/mock_request_id_stub.h)
9798
target_link_libraries(
9899
google_cloud_cpp_generator_golden_testing
99100
PUBLIC google_cloud_cpp_testing google_cloud_cpp_mocks
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_TESTS_MOCK_REQUEST_ID_STUB_H
16+
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_TESTS_MOCK_REQUEST_ID_STUB_H
17+
18+
#include "generator/integration_tests/golden/v1/internal/request_id_stub.h"
19+
#include <gmock/gmock.h>
20+
21+
namespace google {
22+
namespace cloud {
23+
namespace golden_v1_testing {
24+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
25+
26+
class MockRequestIdServiceStub
27+
: public google::cloud::golden_v1_internal::RequestIdServiceStub {
28+
public:
29+
~MockRequestIdServiceStub() override = default;
30+
31+
MOCK_METHOD(StatusOr<google::test::requestid::v1::Foo>, CreateFoo,
32+
(grpc::ClientContext&, Options const&,
33+
google::test::requestid::v1::CreateFooRequest const&),
34+
(override));
35+
36+
MOCK_METHOD(future<StatusOr<google::longrunning::Operation>>, AsyncRenameFoo,
37+
(google::cloud::CompletionQueue&,
38+
std::shared_ptr<grpc::ClientContext>,
39+
google::cloud::internal::ImmutableOptions,
40+
google::test::requestid::v1::RenameFooRequest const&),
41+
(override));
42+
43+
MOCK_METHOD(StatusOr<google::test::requestid::v1::ListFoosResponse>, ListFoos,
44+
(grpc::ClientContext&, Options const&,
45+
google::test::requestid::v1::ListFoosRequest const&),
46+
(override));
47+
48+
MOCK_METHOD(future<StatusOr<google::test::requestid::v1::Foo>>,
49+
AsyncCreateFoo,
50+
(google::cloud::CompletionQueue&,
51+
std::shared_ptr<grpc::ClientContext>,
52+
google::cloud::internal::ImmutableOptions,
53+
google::test::requestid::v1::CreateFooRequest const&),
54+
(override));
55+
56+
MOCK_METHOD(future<StatusOr<google::longrunning::Operation>>,
57+
AsyncGetOperation,
58+
(google::cloud::CompletionQueue&,
59+
std::shared_ptr<grpc::ClientContext>,
60+
google::cloud::internal::ImmutableOptions,
61+
google::longrunning::GetOperationRequest const&),
62+
(override));
63+
64+
MOCK_METHOD(future<Status>, AsyncCancelOperation,
65+
(google::cloud::CompletionQueue&,
66+
std::shared_ptr<grpc::ClientContext>,
67+
google::cloud::internal::ImmutableOptions,
68+
google::longrunning::CancelOperationRequest const&),
69+
(override));
70+
};
71+
72+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
73+
} // namespace golden_v1_testing
74+
} // namespace cloud
75+
} // namespace google
76+
77+
#endif // GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_TESTS_MOCK_REQUEST_ID_STUB_H

generator/integration_tests/tests/request_id_connection_impl_test.cc

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "generator/integration_tests/golden/v1/internal/request_id_connection_impl.h"
1616
#include "generator/integration_tests/golden/v1/internal/request_id_option_defaults.h"
1717
#include "generator/integration_tests/golden/v1/internal/request_id_stub.h"
18+
#include "generator/integration_tests/tests/mock_request_id_stub.h"
1819
#include "google/cloud/grpc_options.h"
1920
#include "google/cloud/options.h"
2021
#include "google/cloud/testing_util/status_matchers.h"
@@ -30,6 +31,7 @@ namespace golden_v1 {
3031
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3132
namespace {
3233

34+
using ::google::cloud::golden_v1_testing::MockRequestIdServiceStub;
3335
using ::google::cloud::testing_util::IsOkAndHolds;
3436
using ::google::test::requestid::v1::CreateFooRequest;
3537
using ::google::test::requestid::v1::Foo;
@@ -44,52 +46,6 @@ using ::testing::IsEmpty;
4446
using ::testing::ResultOf;
4547
using ::testing::Return;
4648

47-
class MockRequestIdServiceStub
48-
: public google::cloud::golden_v1_internal::RequestIdServiceStub {
49-
public:
50-
~MockRequestIdServiceStub() override = default;
51-
52-
MOCK_METHOD(StatusOr<google::test::requestid::v1::Foo>, CreateFoo,
53-
(grpc::ClientContext&, Options const&,
54-
google::test::requestid::v1::CreateFooRequest const&),
55-
(override));
56-
57-
MOCK_METHOD(future<StatusOr<google::longrunning::Operation>>, AsyncRenameFoo,
58-
(google::cloud::CompletionQueue&,
59-
std::shared_ptr<grpc::ClientContext>,
60-
google::cloud::internal::ImmutableOptions,
61-
google::test::requestid::v1::RenameFooRequest const&),
62-
(override));
63-
64-
MOCK_METHOD(StatusOr<google::test::requestid::v1::ListFoosResponse>, ListFoos,
65-
(grpc::ClientContext&, Options const&,
66-
google::test::requestid::v1::ListFoosRequest const&),
67-
(override));
68-
69-
MOCK_METHOD(future<StatusOr<google::test::requestid::v1::Foo>>,
70-
AsyncCreateFoo,
71-
(google::cloud::CompletionQueue&,
72-
std::shared_ptr<grpc::ClientContext>,
73-
google::cloud::internal::ImmutableOptions,
74-
google::test::requestid::v1::CreateFooRequest const&),
75-
(override));
76-
77-
MOCK_METHOD(future<StatusOr<google::longrunning::Operation>>,
78-
AsyncGetOperation,
79-
(google::cloud::CompletionQueue&,
80-
std::shared_ptr<grpc::ClientContext>,
81-
google::cloud::internal::ImmutableOptions,
82-
google::longrunning::GetOperationRequest const&),
83-
(override));
84-
85-
MOCK_METHOD(future<Status>, AsyncCancelOperation,
86-
(google::cloud::CompletionQueue&,
87-
std::shared_ptr<grpc::ClientContext>,
88-
google::cloud::internal::ImmutableOptions,
89-
google::longrunning::CancelOperationRequest const&),
90-
(override));
91-
};
92-
9349
template <typename Request>
9450
auto WithRequestId(std::string expected) {
9551
return ResultOf(

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-cpp/commit/eb5abbaf5c3732f0f37a1a3ba3bd49956a1eefaf

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy