1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

added unit tests for open (adapter)

This commit is contained in:
Falk Werner
2020-04-04 08:32:26 +02:00
parent d56bbcbd39
commit 77a870b9b7
16 changed files with 284 additions and 27 deletions

View File

@@ -1,3 +1,6 @@
#ifndef MOCK_FUSE_HPP
#define MOCK_FUSE_HPP
#include "webfuse/adapter/impl/fuse_wrapper.h"
#include <gmock/gmock.h>
@@ -15,5 +18,6 @@ public:
MOCK_METHOD2(fuse_reply_err, int (fuse_req_t req, int err));
};
}
}
#endif

View File

@@ -0,0 +1,30 @@
#include "webfuse/mocks/mock_jsonrpc_proxy.hpp"
#include "webfuse/utils/wrap.hpp"
extern "C"
{
static webfuse_test::MockJsonRpcProxy * webfuse_test_MockJsonRpcProxy = nullptr;
WF_WRAP_FUNC6(webfuse_test_MockJsonRpcProxy, void, wf_jsonrpc_proxy_vinvoke,
struct wf_jsonrpc_proxy *,
wf_jsonrpc_proxy_finished_fn *,
void *,
char const *,
char const *,
va_list);
}
namespace webfuse_test
{
MockJsonRpcProxy::MockJsonRpcProxy()
{
webfuse_test_MockJsonRpcProxy = this;
}
MockJsonRpcProxy::~MockJsonRpcProxy()
{
webfuse_test_MockJsonRpcProxy = nullptr;
}
}

View File

@@ -0,0 +1,27 @@
#ifndef MOCK_JSONRPC_PROXY_HPP
#define MOCK_JSONRPC_PROXY_HPP
#include "webfuse/core/jsonrpc/proxy_intern.h"
#include <gmock/gmock.h>
namespace webfuse_test
{
class MockJsonRpcProxy
{
public:
MockJsonRpcProxy();
virtual ~MockJsonRpcProxy();
MOCK_METHOD6(wf_jsonrpc_proxy_vinvoke, void (
struct wf_jsonrpc_proxy * proxy,
wf_jsonrpc_proxy_finished_fn * finished,
void * user_data,
char const * method_name,
char const * param_info,
va_list args));
};
}
#endif

View File

@@ -0,0 +1,27 @@
#include "webfuse/mocks/mock_operations_context.hpp"
#include "webfuse/utils/wrap.hpp"
extern "C"
{
static webfuse_test::MockOperationsContext * webfuse_test_MockOperationsContext = nullptr;
WF_WRAP_FUNC1(webfuse_test_MockOperationsContext,
struct wf_jsonrpc_proxy *, wf_impl_operations_context_get_proxy,
struct wf_impl_operations_context *);
}
namespace webfuse_test
{
MockOperationsContext::MockOperationsContext()
{
webfuse_test_MockOperationsContext = this;
}
MockOperationsContext::~MockOperationsContext()
{
webfuse_test_MockOperationsContext = nullptr;
}
}

View File

@@ -0,0 +1,22 @@
#ifndef MOCK_OPERATIONS_CONTEXT_HPP
#define MOCK_OPERATIONS_CONTEXT_HPP
#include "webfuse/adapter/impl/operations.h"
#include <gmock/gmock.h>
namespace webfuse_test
{
class MockOperationsContext
{
public:
MockOperationsContext();
virtual ~MockOperationsContext();
MOCK_METHOD1(wf_impl_operations_context_get_proxy, wf_jsonrpc_proxy * (
struct wf_impl_operations_context * context));
};
}
#endif