Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update mock LRO tips #14609

Merged
merged 3 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,36 @@ class MockGoldenThingAdminConnection : public golden_v1::GoldenThingAdminConnect
ListDatabases,
(google::test::admin::database::v1::ListDatabasesRequest request), (override));

/// Due to additional overloads for this method
/// `EXPECT_CALL(*mock, CreateDatabase)` is now ambiguous. Use
/// `EXPECT_CALL(*mock, CreateDatabase(::testing::_))` instead.
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, CreateDatabase(Matcher<google::test::admin::database::v1::CreateDatabaseRequest const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Database>>,
CreateDatabase,
(google::test::admin::database::v1::CreateDatabaseRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, CreateDatabase(_, _))
/// @endcode
MOCK_METHOD(StatusOr<google::longrunning::Operation>,
CreateDatabase, (NoAwaitTag,
google::test::admin::database::v1::CreateDatabaseRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, CreateDatabase(Matcher<google::longrunning::Operation const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Database>>,
CreateDatabase, (
google::longrunning::Operation const& operation), (override));
Expand All @@ -69,17 +88,36 @@ class MockGoldenThingAdminConnection : public golden_v1::GoldenThingAdminConnect
GetDatabase,
(google::test::admin::database::v1::GetDatabaseRequest const& request), (override));

/// Due to additional overloads for this method
/// `EXPECT_CALL(*mock, UpdateDatabaseDdl)` is now ambiguous. Use
/// `EXPECT_CALL(*mock, UpdateDatabaseDdl(::testing::_))` instead.
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, UpdateDatabaseDdl(Matcher<google::test::admin::database::v1::UpdateDatabaseDdlRequest const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>,
UpdateDatabaseDdl,
(google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, UpdateDatabaseDdl(_, _))
/// @endcode
MOCK_METHOD(StatusOr<google::longrunning::Operation>,
UpdateDatabaseDdl, (NoAwaitTag,
google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, UpdateDatabaseDdl(Matcher<google::longrunning::Operation const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>,
UpdateDatabaseDdl, (
google::longrunning::Operation const& operation), (override));
Expand All @@ -104,17 +142,36 @@ class MockGoldenThingAdminConnection : public golden_v1::GoldenThingAdminConnect
TestIamPermissions,
(google::iam::v1::TestIamPermissionsRequest const& request), (override));

/// Due to additional overloads for this method
/// `EXPECT_CALL(*mock, CreateBackup)` is now ambiguous. Use
/// `EXPECT_CALL(*mock, CreateBackup(::testing::_))` instead.
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, CreateBackup(Matcher<google::test::admin::database::v1::CreateBackupRequest const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Backup>>,
CreateBackup,
(google::test::admin::database::v1::CreateBackupRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, CreateBackup(_, _))
/// @endcode
MOCK_METHOD(StatusOr<google::longrunning::Operation>,
CreateBackup, (NoAwaitTag,
google::test::admin::database::v1::CreateBackupRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, CreateBackup(Matcher<google::longrunning::Operation const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Backup>>,
CreateBackup, (
google::longrunning::Operation const& operation), (override));
Expand All @@ -135,17 +192,36 @@ class MockGoldenThingAdminConnection : public golden_v1::GoldenThingAdminConnect
ListBackups,
(google::test::admin::database::v1::ListBackupsRequest request), (override));

/// Due to additional overloads for this method
/// `EXPECT_CALL(*mock, RestoreDatabase)` is now ambiguous. Use
/// `EXPECT_CALL(*mock, RestoreDatabase(::testing::_))` instead.
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, RestoreDatabase(Matcher<google::test::admin::database::v1::RestoreDatabaseRequest const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Database>>,
RestoreDatabase,
(google::test::admin::database::v1::RestoreDatabaseRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, RestoreDatabase(_, _))
/// @endcode
MOCK_METHOD(StatusOr<google::longrunning::Operation>,
RestoreDatabase, (NoAwaitTag,
google::test::admin::database::v1::RestoreDatabaseRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, RestoreDatabase(Matcher<google::longrunning::Operation const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Database>>,
RestoreDatabase, (
google::longrunning::Operation const& operation), (override));
Expand All @@ -158,17 +234,36 @@ class MockGoldenThingAdminConnection : public golden_v1::GoldenThingAdminConnect
ListBackupOperations,
(google::test::admin::database::v1::ListBackupOperationsRequest request), (override));

/// Due to additional overloads for this method
/// `EXPECT_CALL(*mock, LongRunningWithoutRouting)` is now ambiguous. Use
/// `EXPECT_CALL(*mock, LongRunningWithoutRouting(::testing::_))` instead.
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, LongRunningWithoutRouting(Matcher<google::test::admin::database::v1::RestoreDatabaseRequest const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Database>>,
LongRunningWithoutRouting,
(google::test::admin::database::v1::RestoreDatabaseRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, LongRunningWithoutRouting(_, _))
/// @endcode
MOCK_METHOD(StatusOr<google::longrunning::Operation>,
LongRunningWithoutRouting, (NoAwaitTag,
google::test::admin::database::v1::RestoreDatabaseRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, LongRunningWithoutRouting(Matcher<google::longrunning::Operation const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::admin::database::v1::Database>>,
LongRunningWithoutRouting, (
google::longrunning::Operation const& operation), (override));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,36 @@ class MockRequestIdServiceConnection : public golden_v1::RequestIdServiceConnect
CreateFoo,
(google::test::requestid::v1::CreateFooRequest const& request), (override));

/// Due to additional overloads for this method
/// `EXPECT_CALL(*mock, RenameFoo)` is now ambiguous. Use
/// `EXPECT_CALL(*mock, RenameFoo(::testing::_))` instead.
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, RenameFoo(Matcher<google::test::requestid::v1::RenameFooRequest const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::requestid::v1::Foo>>,
RenameFoo,
(google::test::requestid::v1::RenameFooRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, RenameFoo(_, _))
/// @endcode
MOCK_METHOD(StatusOr<google::longrunning::Operation>,
RenameFoo, (NoAwaitTag,
google::test::requestid::v1::RenameFooRequest const& request), (override));


/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, RenameFoo(Matcher<google::longrunning::Operation const&>(_)))
/// @endcode
MOCK_METHOD(future<StatusOr<google::test::requestid::v1::Foo>>,
RenameFoo, (
google::longrunning::Operation const& operation), (override));
Expand Down
32 changes: 27 additions & 5 deletions generator/internal/mock_connection_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,47 @@ class $mock_connection_class_name$ : public $product_namespace$::$connection_cla
Not(IsPaginated))),
MethodPattern(
{
{// clang-format off
"\n /// Due to additional overloads for this method\n"
" /// `EXPECT_CALL(*mock, $method_name$)` is now ambiguous. Use\n"
" /// `EXPECT_CALL(*mock, $method_name$(::testing::_))` instead.\n"},
// clang-format on
{
R"""(
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, $method_name$(Matcher<$request_type$ const&>(_)))
/// @endcode
)"""},
{IsResponseTypeEmpty,
// clang-format off
" MOCK_METHOD(future<Status>,\n",
" MOCK_METHOD(future<StatusOr<$longrunning_deduced_response_type$>>,\n"},
{" $method_name$,\n"
" ($request_type$ const& request), (override));\n\n",},
// clang-format on
{R"""(
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// EXPECT_CALL(*mock, $method_name$(_, _))
/// @endcode
)"""},
{IsResponseTypeEmpty,
// clang-format off
" MOCK_METHOD(Status,\n",
" MOCK_METHOD(StatusOr<$longrunning_operation_type$>,\n"},
{" $method_name$, (NoAwaitTag,\n"
" $request_type$ const& request), (override));\n\n"},
// clang-format on
{R"""(
/// To disambiguate calls, use:
///
/// @code
/// using ::testing::_;
/// using ::testing::Matcher;
/// EXPECT_CALL(*mock, $method_name$(Matcher<$longrunning_operation_type$ const&>(_)))
/// @endcode
)"""},
{IsResponseTypeEmpty,
// clang-format off
" MOCK_METHOD(future<Status>,\n",
Expand Down
Loading
Loading