]>
git.proxmox.com Git - ceph.git/blob - 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
4 #ifndef LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H
5 #define LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H
7 #include "test/librados_test_stub/TestMemRadosClient.h"
8 #include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
9 #include "gmock/gmock.h"
15 class MockTestMemRadosClient
: public TestMemRadosClient
{
17 MockTestMemRadosClient(CephContext
*cct
, TestMemCluster
*test_mem_cluster
)
18 : TestMemRadosClient(cct
, test_mem_cluster
) {
19 default_to_dispatch();
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
));
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
);
38 void default_to_dispatch() {
39 using namespace ::testing
;
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
));
46 } // namespace librados
48 #endif // LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H