]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/librados_test_stub/MockTestMemRadosClient.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / test / librados_test_stub / MockTestMemRadosClient.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H
5 #define LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H
6
7 #include "test/librados_test_stub/TestMemRadosClient.h"
8 #include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
9 #include "gmock/gmock.h"
10
11 namespace librados {
12
13 class TestMemCluster;
14
15 class MockTestMemRadosClient : public TestMemRadosClient {
16 public:
17 MockTestMemRadosClient(CephContext *cct, TestMemCluster *test_mem_cluster)
18 : TestMemRadosClient(cct, test_mem_cluster) {
19 default_to_dispatch();
20 }
21
22 MOCK_METHOD2(create_ioctx, TestIoCtxImpl *(int64_t pool_id,
23 const std::string &pool_name));
24 TestIoCtxImpl *do_create_ioctx(int64_t pool_id,
25 const std::string &pool_name) {
26 return new ::testing::NiceMock<MockTestMemIoCtxImpl>(
27 this, this, pool_id, pool_name,
28 get_mem_cluster()->get_pool(pool_name));
29 }
30
31 MOCK_METHOD2(blacklist_add, int(const std::string& client_address,
32 uint32_t expire_seconds));
33 int do_blacklist_add(const std::string& client_address,
34 uint32_t expire_seconds) {
35 return TestMemRadosClient::blacklist_add(client_address, expire_seconds);
36 }
37
38 void default_to_dispatch() {
39 using namespace ::testing;
40
41 ON_CALL(*this, create_ioctx(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_create_ioctx));
42 ON_CALL(*this, blacklist_add(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_blacklist_add));
43 }
44 };
45
46 } // namespace librados
47
48 #endif // LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H