summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Burton <ross@linux.intel.com>2010-03-06 17:59:08 +0000
committerRoss Burton <ross@linux.intel.com>2010-08-13 11:03:14 +0100
commitb186c3b7be9ac519db0ecabd0252bc8ea0571f06 (patch)
tree51135ccf64f1ddc4f5d103efac37ac3e9b4070a2
parent53252f0867876584274c12274b02bf75c064f6da (diff)
downloadlibrest-b186c3b7be9ac519db0ecabd0252bc8ea0571f06.tar.gz
Add basic test for rest_proxy_call_invoke
-rw-r--r--tests/proxy.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/proxy.c b/tests/proxy.c
index 2beb146..8bcf4be 100644
--- a/tests/proxy.c
+++ b/tests/proxy.c
@@ -275,6 +275,45 @@ test_status_ok (RestProxy *proxy, const char *function)
g_object_unref (call);
}
+static void
+status_ok_cb (GObject *object, GAsyncResult *result, gpointer user_data)
+{
+ RestProxyCall *call = REST_PROXY_CALL (object);
+ GError *error = NULL;
+ int status = GPOINTER_TO_INT (user_data);
+
+ if (call == NULL) {
+ errors++;
+ return;
+ }
+
+ if (!rest_proxy_call_invoke_finish (call, result, &error)) {
+ g_printerr ("Call failed: %s\n", error->message);
+ errors++;
+ }
+
+ if (rest_proxy_call_get_status_code (call) != status) {
+ g_printerr ("wrong response code, got %d\n", rest_proxy_call_get_status_code (call));
+ errors++;
+ return;
+ }
+
+ /* TODO: arrange it so that call is unreffed after this callback? */
+ g_object_unref (call);
+}
+
+static void
+status_ok_test_async (RestProxy *proxy, int status)
+{
+ RestProxyCall *call;
+
+ call = rest_proxy_new_call (proxy);
+ rest_proxy_call_set_function (call, "status");
+ rest_proxy_call_add_param (call, "status", g_strdup_printf ("%d", status));
+
+ rest_proxy_call_invoke (call, NULL, NULL, status_ok_cb, GINT_TO_POINTER (status));
+}
+
int
main (int argc, char **argv)
{
@@ -305,6 +344,9 @@ main (int argc, char **argv)
status_error_test (proxy, SOUP_STATUS_BAD_REQUEST);
status_error_test (proxy, SOUP_STATUS_NOT_IMPLEMENTED);
+ status_ok_test_async (proxy, SOUP_STATUS_OK);
+ status_ok_test_async (proxy, SOUP_STATUS_NO_CONTENT);
+
test_status_ok (proxy, "useragent/none");
rest_proxy_set_user_agent (proxy, "TestSuite-1.0");
test_status_ok (proxy, "useragent/testsuite");