[librest/wip/baedert/tests: 23/27] tests/proxy: Add _add_param_full test



commit be924f33b182acc927b30227f38f5c329a33222d
Author: Timm Bäder <mail baedert org>
Date:   Fri Sep 30 21:12:47 2016 +0200

    tests/proxy: Add _add_param_full test

 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 ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]