mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
removed unused code
This commit is contained in:
parent
b156e298b5
commit
32c9e45e1f
@ -49,33 +49,3 @@ wfp_jsonrpc_request_get_userdata(
|
||||
{
|
||||
return request->user_data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wfp_jsonrpc_respond(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
json_t * result)
|
||||
{
|
||||
json_t * response = json_object();
|
||||
json_object_set_new(response, "result", result);
|
||||
json_object_set_new(response, "id", json_integer(request->id));
|
||||
|
||||
request->send(response, request->user_data);
|
||||
json_decref(response);
|
||||
wfp_jsonrpc_request_dispose(request);
|
||||
}
|
||||
|
||||
void wfp_jsonrpc_respond_error(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
int code,
|
||||
char const * message)
|
||||
{
|
||||
json_t * response = json_object();
|
||||
json_object_set_new(response, "error", wfp_jsonrpc_error(code, message));
|
||||
json_object_set_new(response, "id", json_integer(request->id));
|
||||
|
||||
request->send(response, request->user_data);
|
||||
json_decref(response);
|
||||
wfp_jsonrpc_request_dispose(request);
|
||||
}
|
||||
|
||||
|
@ -36,16 +36,6 @@ extern void wfp_jsonrpc_request_dispose(
|
||||
extern void * wfp_jsonrpc_request_get_userdata(
|
||||
struct wfp_jsonrpc_request * request);
|
||||
|
||||
extern void wfp_jsonrpc_respond(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
json_t * result);
|
||||
|
||||
extern void wfp_jsonrpc_respond_error(
|
||||
struct wfp_jsonrpc_request * request,
|
||||
int code,
|
||||
char const * message);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -37,71 +37,6 @@ TEST(wfp_jsonrpc_request, create_dispose)
|
||||
wfp_jsonrpc_request_dispose(request);
|
||||
}
|
||||
|
||||
TEST(wfp_jsonrpc_request, respond)
|
||||
{
|
||||
Context context{nullptr};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
|
||||
struct wfp_jsonrpc_request * request =
|
||||
wfp_jsonrpc_request_create(42, &jsonrpc_send, user_data);
|
||||
|
||||
wfp_jsonrpc_respond(request, json_string("okay"));
|
||||
|
||||
ASSERT_NE(nullptr, context.response);
|
||||
|
||||
|
||||
json_t * response = reinterpret_cast<json_t*>(context.response);
|
||||
ASSERT_TRUE(json_is_object(response));
|
||||
|
||||
json_t * id = json_object_get(response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
ASSERT_EQ(42, json_integer_value(id));
|
||||
|
||||
json_t * result = json_object_get(response, "result");
|
||||
ASSERT_TRUE(json_is_string(result));
|
||||
ASSERT_STREQ("okay", json_string_value(result));
|
||||
|
||||
ASSERT_EQ(nullptr, json_object_get(response, "error"));
|
||||
|
||||
json_decref(response);
|
||||
}
|
||||
|
||||
TEST(wfp_jsonrpc_request, respond_error)
|
||||
{
|
||||
Context context{nullptr};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
|
||||
struct wfp_jsonrpc_request * request =
|
||||
wfp_jsonrpc_request_create(42, &jsonrpc_send, user_data);
|
||||
|
||||
wfp_jsonrpc_respond_error(request, WFP_BAD, "Bad");
|
||||
|
||||
ASSERT_NE(nullptr, context.response);
|
||||
|
||||
|
||||
json_t * response = reinterpret_cast<json_t*>(context.response);
|
||||
ASSERT_TRUE(json_is_object(response));
|
||||
|
||||
json_t * id = json_object_get(response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
ASSERT_EQ(42, json_integer_value(id));
|
||||
|
||||
ASSERT_EQ(nullptr, json_object_get(response, "result"));
|
||||
|
||||
json_t * err = json_object_get(response, "error");
|
||||
ASSERT_TRUE(json_is_object(err));
|
||||
|
||||
json_t * err_code = json_object_get(err, "code");
|
||||
ASSERT_TRUE(json_is_integer(err_code));
|
||||
ASSERT_EQ(WFP_BAD, json_integer_value(err_code));
|
||||
|
||||
json_t * err_message = json_object_get(err, "message");
|
||||
ASSERT_TRUE(json_is_string(err_message));
|
||||
ASSERT_STREQ("Bad", json_string_value(err_message));
|
||||
|
||||
json_decref(response);
|
||||
}
|
||||
|
||||
TEST(wfp_jsonrpc_request, is_request_object_params)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
|
Loading…
Reference in New Issue
Block a user