userver: storages::redis::MockSubscriptionTokenImpl Class Reference
Loading...
Searching...
No Matches
storages::redis::MockSubscriptionTokenImpl Class Reference

#include <userver/storages/redis/mock_subscribe_client.hpp>

Detailed Description

Mocked storages::redis::SubscriptionToken.

Although one can used it by itself, it mostly for use with MockSubscribeClient. Here is a small example on how to use this class

// Create a mocked subscribe client
MockSubscribeClient client_mock;
// Create a mocked token explicitly to set expectations on it.
auto token_mock = std::make_unique<MockSubscriptionTokenImpl>();
using testing::_;
// Expect that Unsubscribe() is called strictly once.
EXPECT_CALL(*token_mock, Unsubscribe).Times(1);
// Here is how to return a mocked token from Subscribe method.
// Beware that after this line of code, token_mock will be nullptr!
EXPECT_CALL(client_mock, Subscribe("test_subscribe", _, _))
.Times(1)
.WillOnce(testing::Return(::testing::ByMove(SubscriptionToken{std::move(token_mock)})));
// Check that wrong calls aren't there
EXPECT_CALL(client_mock, Psubscribe("test_subscribe", _, _)).Times(0);
// Call Subscribe, get token. Inside this token there should be
// our token_mock impl
auto token = client_mock.Subscribe("test_subscribe", {}, {});
// Can't get access to it, but we can check that something is actually
// inside the token.
EXPECT_FALSE(token.IsEmpty());
token.Unsubscribe();

Definition at line 76 of file mock_subscribe_client.hpp.

Inheritance diagram for storages::redis::MockSubscriptionTokenImpl:

Public Member Functions

 MOCK_METHOD (void, SetMaxQueueLength,(size_t length),(override))
 MOCK_METHOD (void, Unsubscribe,(),(override))

The documentation for this class was generated from the following file: