test-ecal-create-object: Fixed to assert something that makes sense.
[platform/upstream/evolution-data-server.git] / tests / libecal / test-ecal-create-object.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 #include <stdlib.h>
4 #include <libecal/libecal.h>
5 #include <libical/ical.h>
6
7 #include "ecal-test-utils.h"
8 #include "e-test-server-utils.h"
9
10 static ETestServerClosure cal_closure =
11         { E_TEST_SERVER_DEPRECATED_CALENDAR, NULL, E_CAL_SOURCE_TYPE_EVENT };
12
13 static void
14 test_create_object (ETestServerFixture *fixture,
15                     gconstpointer user_data)
16 {
17         ECal *cal;
18         icalcomponent *component;
19         icalcomponent *component_final;
20         gchar *uid;
21
22         cal = E_TEST_SERVER_UTILS_SERVICE (fixture, ECal);
23
24         component = icalcomponent_new (ICAL_VEVENT_COMPONENT);
25         uid = ecal_test_utils_cal_create_object (cal, component);
26
27         /* Assert that we can fetch the newly created component
28          * and that it's valid
29          */
30         component_final = ecal_test_utils_cal_get_object (cal, uid);
31         g_assert (component_final);
32         g_assert (icalcomponent_is_valid (component_final));
33
34         g_free (uid);
35         icalcomponent_free (component);
36         icalcomponent_free (component_final);
37 }
38
39 gint
40 main (gint argc,
41       gchar **argv)
42 {
43 #if !GLIB_CHECK_VERSION (2, 35, 1)
44         g_type_init ();
45 #endif
46         g_test_init (&argc, &argv, NULL);
47
48         g_test_add (
49                 "/ECal/CreateObject", ETestServerFixture, &cal_closure,
50                 e_test_server_utils_setup, test_create_object, e_test_server_utils_teardown);
51
52         return e_test_server_utils_run ();
53 }