google/cloud/pubsub/subscription_admin_connection_test.cc
/**
 * @test Verify DeleteTopic() and logging works.
 *
 * We use this test for both DeleteTopic and logging. DeleteTopic has a simple
 * return type, so it is a good candidate to do the logging test too.
 */
@test Verify DeleteTopic() and logging works.
We use this test for both DeleteTopic and logging. DeleteTopic has a simple
return type, so it is a good candidate to do the logging test too.
@test Verify DeleteTopic () and logging works . We use this test for both DeleteTopic and logging . DeleteTopic has a simple return type so it is a good candidate to do the logging test too .
TEST(SubscriptionAdminConnectionTest, DeleteWithLogging) {
  auto mock = std::make_shared<pubsub_testing::MockSubscriberStub>();
  Subscription const subscription("test-project", "test-subscription");
  auto backend =
      std::make_shared<google::cloud::testing_util::CaptureLogLinesBackend>();
  auto id = google::cloud::LogSink::Instance().AddBackend(backend);
  EXPECT_CALL(*mock, DeleteSubscription)
      .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again")))
      .WillOnce(
          [&](grpc::ClientContext&,
              google::pubsub::v1::DeleteSubscriptionRequest const& request) {
            EXPECT_EQ(subscription.FullName(), request.subscription());
            return Status{};
          });
  auto subscription_admin = pubsub_internal::MakeSubscriptionAdminConnection(
      ConnectionOptions{}.enable_tracing("rpc"), mock, TestRetryPolicy(),
      TestBackoffPolicy());
  auto response = subscription_admin->DeleteSubscription({subscription});
  ASSERT_STATUS_OK(response);
  EXPECT_THAT(backend->ClearLogLines(),
              Contains(HasSubstr("DeleteSubscription")));
  google::cloud::LogSink::Instance().RemoveBackend(id);
}
TEST ( SubscriptionAdminConnectionTest , DeleteWithLogging ) { auto mock = std :: make_shared < pubsub_testing :: MockSubscriberStub > ( ) ; Subscription const subscription ( " " , " " ) ; auto backend = std :: make_shared < google :: cloud :: testing_util :: CaptureLogLinesBackend > ( ) ; auto id = google :: cloud :: LogSink :: Instance ( ) . AddBackend ( backend ) ; EXPECT_CALL ( * mock , DeleteSubscription ) . WillOnce ( Return ( Status ( StatusCode :: kUnavailable , " " ) ) ) . WillOnce ( [ & ] ( grpc :: ClientContext & , google :: pubsub :: v1 :: DeleteSubscriptionRequest const & request ) { EXPECT_EQ ( subscription . FullName ( ) , request . subscription ( ) ) ; return Status { } ; } ) ; auto subscription_admin = pubsub_internal :: MakeSubscriptionAdminConnection ( ConnectionOptions { } . enable_tracing ( " " ) , mock , TestRetryPolicy ( ) , TestBackoffPolicy ( ) ) ; auto response = subscription_admin -> DeleteSubscription ( { subscription } ) ; ASSERT_STATUS_OK ( response ) ; EXPECT_THAT ( backend -> ClearLogLines ( ) , Contains ( HasSubstr ( " " ) ) ) ; google :: cloud :: LogSink :: Instance ( ) . RemoveBackend ( id ) ; }
@test Verify DeleteTopic() and logging works.
@test Verify DeleteTopic () and logging works .