mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 00:03:12 +02:00
relay/api: add GET /api/hotlist
This commit is contained in:
@@ -34,6 +34,7 @@ extern "C"
|
||||
#include "src/core/core-version.h"
|
||||
#include "src/gui/gui-buffer.h"
|
||||
#include "src/gui/gui-chat.h"
|
||||
#include "src/gui/gui-hotlist.h"
|
||||
#include "src/gui/gui-line.h"
|
||||
#include "src/plugins/weechat-plugin.h"
|
||||
#include "src/plugins/relay/relay.h"
|
||||
@@ -476,6 +477,68 @@ TEST(RelayApiProtocolWithClient, CbBuffers)
|
||||
LONGS_EQUAL(0, cJSON_GetArraySize (json_groups));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* relay_api_protocol_cb_hotlist
|
||||
*/
|
||||
|
||||
TEST(RelayApiProtocolWithClient, CbHotlist)
|
||||
{
|
||||
cJSON *json, *json_obj, *json_count;
|
||||
|
||||
/* get hotlist (empty) */
|
||||
test_client_recv_http ("GET /api/hotlist", NULL);
|
||||
WEE_CHECK_HTTP_CODE(200, "OK");
|
||||
CHECK(json_body_sent);
|
||||
CHECK(cJSON_IsArray (json_body_sent));
|
||||
LONGS_EQUAL(0, cJSON_GetArraySize (json_body_sent));
|
||||
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_LOW, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_MESSAGE, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_MESSAGE, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_PRIVATE, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_PRIVATE, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_PRIVATE, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_HIGHLIGHT, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_HIGHLIGHT, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_HIGHLIGHT, NULL, 0);
|
||||
gui_hotlist_add (gui_buffers, GUI_HOTLIST_HIGHLIGHT, NULL, 0);
|
||||
|
||||
/* get hotlist (one buffer) */
|
||||
test_client_recv_http ("GET /api/hotlist", NULL);
|
||||
WEE_CHECK_HTTP_CODE(200, "OK");
|
||||
CHECK(json_body_sent);
|
||||
CHECK(cJSON_IsArray (json_body_sent));
|
||||
LONGS_EQUAL(1, cJSON_GetArraySize (json_body_sent));
|
||||
json = cJSON_GetArrayItem (json_body_sent, 0);
|
||||
CHECK(json);
|
||||
CHECK(cJSON_IsObject (json));
|
||||
WEE_CHECK_OBJ_NUM(GUI_HOTLIST_HIGHLIGHT, json, "priority");
|
||||
CHECK(cJSON_IsString (cJSON_GetObjectItem (json, "date")));
|
||||
WEE_CHECK_OBJ_NUM(gui_buffers->id, json, "buffer_id");
|
||||
json_count = cJSON_GetObjectItem (json, "count");
|
||||
CHECK(json_count);
|
||||
CHECK(cJSON_IsArray (json_count));
|
||||
json_obj = cJSON_GetArrayItem (json_count, 0);
|
||||
CHECK(json_obj);
|
||||
CHECK(cJSON_IsNumber (json_obj));
|
||||
CHECK(1 == cJSON_GetNumberValue (json_obj));
|
||||
json_obj = cJSON_GetArrayItem (json_count, 1);
|
||||
CHECK(json_obj);
|
||||
CHECK(cJSON_IsNumber (json_obj));
|
||||
CHECK(2 == cJSON_GetNumberValue (json_obj));
|
||||
json_obj = cJSON_GetArrayItem (json_count, 2);
|
||||
CHECK(json_obj);
|
||||
CHECK(cJSON_IsNumber (json_obj));
|
||||
CHECK(3 == cJSON_GetNumberValue (json_obj));
|
||||
json_obj = cJSON_GetArrayItem (json_count, 3);
|
||||
CHECK(json_obj);
|
||||
CHECK(cJSON_IsNumber (json_obj));
|
||||
CHECK(4 == cJSON_GetNumberValue (json_obj));
|
||||
|
||||
gui_hotlist_remove_buffer (gui_buffers, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* relay_api_protocol_cb_input
|
||||
|
||||
Reference in New Issue
Block a user