Code

store: Drop the global (default) store.
[sysdb.git] / t / unit / frontend / query_test.c
index 7fb73a453f33dc7bf84a8989557f8c9470f93b10..5330999c2d091e9828b00dc9d0c01fb1509b810a 100644 (file)
 static void
 populate(void)
 {
+       sdb_store_t *store;
        sdb_data_t datum;
 
-       sdb_store_init();
+       /* the frontend accesses the store via the plugin API */
+       store = sdb_store_create();
+       ck_assert(store != NULL);
+       ck_assert(sdb_plugin_register_writer("test-writer",
+                               &sdb_store_writer, SDB_OBJ(store)) == 0);
+       ck_assert(sdb_plugin_register_reader("test-reader",
+                               &sdb_store_reader, SDB_OBJ(store)) == 0);
+       sdb_object_deref(SDB_OBJ(store));
 
+       /* populate the store */
        sdb_plugin_store_host("h1", 1 * SDB_INTERVAL_SECOND);
        sdb_plugin_store_host("h2", 3 * SDB_INTERVAL_SECOND);
 
@@ -78,6 +87,12 @@ populate(void)
                        &datum, 1 * SDB_INTERVAL_SECOND);
 } /* populate */
 
+static void
+turndown(void)
+{
+       sdb_plugin_unregister_all();
+} /* turndown */
+
 #define HOST_H1 \
        "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", " \
                        "\"update_interval\": \"0s\", \"backends\": [], " \
@@ -732,7 +747,7 @@ END_TEST
 TEST_MAIN("frontend::query")
 {
        TCase *tc = tcase_create("core");
-       tcase_add_checked_fixture(tc, populate, sdb_store_clear);
+       tcase_add_checked_fixture(tc, populate, turndown);
        TC_ADD_LOOP_TEST(tc, query);
        ADD_TCASE(tc);
 }