2020-04-04 06:55:59 +00:00
|
|
|
#include "webfuse/adapter/impl/operation/close.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "webfuse/mocks/mock_fuse.hpp"
|
2020-04-04 21:27:34 +00:00
|
|
|
#include "webfuse/mocks/mock_operation_context.hpp"
|
2020-04-04 06:55:59 +00:00
|
|
|
#include "webfuse/mocks/mock_jsonrpc_proxy.hpp"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
using webfuse_test::MockJsonRpcProxy;
|
2020-04-04 21:27:34 +00:00
|
|
|
using webfuse_test::MockOperationContext;
|
2020-04-04 06:55:59 +00:00
|
|
|
using webfuse_test::FuseMock;
|
|
|
|
using testing::_;
|
|
|
|
using testing::Return;
|
|
|
|
using testing::StrEq;
|
|
|
|
|
|
|
|
TEST(wf_impl_operation_close, notify_proxy)
|
|
|
|
{
|
|
|
|
MockJsonRpcProxy proxy;
|
2020-04-04 10:49:02 +00:00
|
|
|
EXPECT_CALL(proxy, wf_jsonrpc_proxy_vnotify(_,StrEq("close"),StrEq("siii"))).Times(1);
|
2020-04-04 06:55:59 +00:00
|
|
|
|
2020-04-04 21:27:34 +00:00
|
|
|
MockOperationContext context;
|
|
|
|
EXPECT_CALL(context, wf_impl_operation_context_get_proxy(_)).Times(1)
|
2020-04-04 06:55:59 +00:00
|
|
|
.WillOnce(Return(reinterpret_cast<wf_jsonrpc_proxy*>(&proxy)));
|
|
|
|
|
2020-04-04 21:27:34 +00:00
|
|
|
wf_impl_operation_context op_context;
|
2020-04-04 06:55:59 +00:00
|
|
|
op_context.name = nullptr;
|
|
|
|
FuseMock fuse;
|
|
|
|
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1).WillOnce(Return(&op_context));
|
|
|
|
EXPECT_CALL(fuse, fuse_reply_err(_, 0)).Times(1).WillOnce(Return(0));
|
|
|
|
|
|
|
|
fuse_req_t request = nullptr;
|
|
|
|
fuse_ino_t inode = 1;
|
|
|
|
fuse_file_info file_info;
|
|
|
|
file_info.flags = 0;
|
|
|
|
wf_impl_operation_close(request, inode, &file_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(wf_impl_operation_close, fail_rpc_null)
|
|
|
|
{
|
|
|
|
MockJsonRpcProxy proxy;
|
2020-04-04 10:49:02 +00:00
|
|
|
EXPECT_CALL(proxy, wf_jsonrpc_proxy_vnotify(_,_,_)).Times(0);
|
2020-04-04 06:55:59 +00:00
|
|
|
|
2020-04-04 21:27:34 +00:00
|
|
|
MockOperationContext context;
|
|
|
|
EXPECT_CALL(context, wf_impl_operation_context_get_proxy(_)).Times(1)
|
2020-04-04 06:55:59 +00:00
|
|
|
.WillOnce(Return(nullptr));
|
|
|
|
|
|
|
|
FuseMock fuse;
|
|
|
|
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1).WillOnce(Return(nullptr));
|
|
|
|
EXPECT_CALL(fuse, fuse_reply_err(_, 0)).Times(1).WillOnce(Return(0));
|
|
|
|
|
|
|
|
fuse_req_t request = nullptr;
|
|
|
|
fuse_ino_t inode = 1;
|
|
|
|
fuse_file_info * file_info = nullptr;
|
|
|
|
wf_impl_operation_close(request, inode, file_info);
|
|
|
|
}
|