diff options
author | Timm Bäder <mail@baedert.org> | 2016-09-30 21:12:47 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2017-02-21 17:41:38 +0100 |
commit | be924f33b182acc927b30227f38f5c329a33222d (patch) | |
tree | 4ab468e49ce09075aec0c4dd5e95416c1b057584 | |
parent | 03f21eddb06092f25f6056a40945c4cc1434c2e1 (diff) | |
download | librest-be924f33b182acc927b30227f38f5c329a33222d.tar.gz |
tests/proxy: Add _add_param_full test
-rw-r--r-- | tests/proxy.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/proxy.c b/tests/proxy.c index e9ad394..dbe95ae 100644 --- a/tests/proxy.c +++ b/tests/proxy.c @@ -325,6 +325,62 @@ cancel () test_server_stop (server); } +static void +param_full_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) +{ + RestProxyCall *call = REST_PROXY_CALL (source_object); + GMainLoop *main_loop = user_data; + GError *error = NULL; + gboolean success; + + success= rest_proxy_call_invoke_finish (call, result, &error); + g_assert (success); + g_assert_no_error (error); + + g_main_loop_quit (main_loop); +} + +static void +param_full () +{ + TestServer *server = test_server_create (server_callback); + RestProxy *proxy = rest_proxy_new (server->url, FALSE); + RestProxyCall *call; + RestParam *param; + GMainLoop *main_loop; + guchar data[] = {1,2,3,4,5,6,7,8,9,10}; + + test_server_run (server); + + main_loop = g_main_loop_new (NULL, FALSE); + call = rest_proxy_new_call (proxy); + rest_proxy_call_set_function (call, "useragent/none"); + + param = rest_param_new_full ("some-param-name", + REST_MEMORY_COPY, + data, + sizeof (data), + "multipart/form-data", + "some-filename.png"); + rest_proxy_call_add_param_full (call, param); + + rest_proxy_call_invoke_async (call, + NULL, + param_full_cb, + main_loop); + + g_main_loop_run (main_loop); + + + + g_main_loop_unref (main_loop); + g_object_unref (proxy); + g_object_unref (call); + test_server_stop (server); +} + int main (int argc, char **argv) { @@ -336,6 +392,7 @@ main (int argc, char **argv) g_test_add_func ("/proxy/fail", fail); g_test_add_func ("/proxy/useragent", useragent); g_test_add_func ("/proxy/cancel", cancel); + g_test_add_func ("/proxy/param-full", param_full); return g_test_run (); } |