mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
added tests for wfp_impl_getattr
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
#include "webfuse/mocks/mock_request.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace
|
||||
extern "C"
|
||||
{
|
||||
|
||||
extern "C" void
|
||||
respond(
|
||||
static void webfuse_test_MockRequest_respond(
|
||||
json_t * response,
|
||||
void * user_data)
|
||||
{
|
||||
webfuse_test::Request * request = reinterpret_cast<webfuse_test::Request*>(user_data);
|
||||
auto * request = reinterpret_cast<webfuse_test::MockRequest*>(user_data);
|
||||
|
||||
json_t * result = json_object_get(response, "result");
|
||||
json_t * error = json_object_get(response, "error");
|
||||
@@ -31,21 +30,17 @@ respond(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
namespace webfuse_test
|
||||
{
|
||||
|
||||
struct wfp_request *
|
||||
request_create(
|
||||
Request * req,
|
||||
int id)
|
||||
struct wfp_request * MockRequest::create_request(int id)
|
||||
{
|
||||
struct wfp_request * request = reinterpret_cast<struct wfp_request *>(malloc(sizeof(struct wfp_request)));
|
||||
auto * request = reinterpret_cast<wfp_request*>(malloc(sizeof(wfp_request)));
|
||||
request->respond = &webfuse_test_MockRequest_respond;
|
||||
request->user_data = reinterpret_cast<void*>(this);
|
||||
request->id = id;
|
||||
request->user_data = reinterpret_cast<void*>(req);
|
||||
request->respond = &respond;
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -10,26 +10,14 @@
|
||||
namespace webfuse_test
|
||||
{
|
||||
|
||||
class Request
|
||||
{
|
||||
public:
|
||||
virtual ~Request() { }
|
||||
virtual void respond(json_t * result, int id) = 0;
|
||||
virtual void respond_error(json_t * error, int id) = 0;
|
||||
};
|
||||
|
||||
class MockRequest: public Request
|
||||
class MockRequest
|
||||
{
|
||||
public:
|
||||
struct wfp_request * create_request(int id);
|
||||
MOCK_METHOD2(respond, void(json_t * result, int id));
|
||||
MOCK_METHOD2(respond_error, void(json_t * error, int id));
|
||||
};
|
||||
|
||||
extern struct wfp_request *
|
||||
request_create(
|
||||
Request * req,
|
||||
int id);
|
||||
|
||||
MATCHER_P3(GetAttrMatcher, inode, mode, file_type, "")
|
||||
{
|
||||
json_t * inode_holder = json_object_get(arg, "inode");
|
||||
|
||||
Reference in New Issue
Block a user