Code

Replaced sdb_store_<type> with sdb_plugin_store_<type>.
[sysdb.git] / t / unit / core / store_lookup_test.c
index 33c9268cb01d29fc561987b9838eb86f12b213f6..49f2268a24d0758dc5165934bb5c75d7908a9947 100644 (file)
 #      include "config.h"
 #endif
 
+#include "core/plugin.h"
 #include "core/store.h"
 #include "core/store-private.h"
 #include "parser/parser.h"
 #include "testutils.h"
 
-#include <assert.h>
-
 #include <check.h>
 #include <string.h>
 
@@ -75,34 +74,36 @@ populate(void)
 
        size_t i;
 
+       sdb_store_init();
+
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hosts); ++i) {
-               int status = sdb_store_host(hosts[i], 1);
+               int status = sdb_plugin_store_host(hosts[i], 1);
                fail_unless(status == 0,
-                               "sdb_store_host(%s, 1) = %d; expected: 0",
+                               "sdb_plugin_store_host(%s, 1) = %d; expected: 0",
                                hosts[i], status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
-               int status = sdb_store_metric(metrics[i].host,
+               int status = sdb_plugin_store_metric(metrics[i].host,
                                metrics[i].metric, /* store */ NULL, 1);
                fail_unless(status == 0,
-                               "sdb_store_metric(%s, %s, NULL, 1) = %d; expected: 0",
+                               "sdb_plugin_store_metric(%s, %s, NULL, 1) = %d; expected: 0",
                                metrics[i].host, metrics[i].metric, status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
-               int status = sdb_store_service(services[i].host,
+               int status = sdb_plugin_store_service(services[i].host,
                                services[i].service, 1);
                fail_unless(status == 0,
-                               "sdb_store_service(%s, %s, 1) = %d; expected: 0",
+                               "sdb_plugin_store_service(%s, %s, 1) = %d; expected: 0",
                                services[i].host, services[i].service, status);
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(attrs); ++i) {
-               int status = sdb_store_attribute(attrs[i].host,
+               int status = sdb_plugin_store_attribute(attrs[i].host,
                                attrs[i].name, &attrs[i].value, 1);
                fail_unless(status == 0,
-                               "sdb_store_attribute(%s, %s, <val>, 1) = %d; expected: 0",
+                               "sdb_plugin_store_attribute(%s, %s, <val>, 1) = %d; expected: 0",
                                attrs[i].host, attrs[i].name, status);
        }
 } /* populate */
@@ -265,7 +266,7 @@ START_TEST(test_cmp_attr)
        };
 
        const char *op_str[] = { "<", "<=", "=", ">=", ">" };
-       assert(SDB_STATIC_ARRAY_LEN(tests) == SDB_STATIC_ARRAY_LEN(op_str));
+       ck_assert(SDB_STATIC_ARRAY_LEN(tests) == SDB_STATIC_ARRAY_LEN(op_str));
 
        host = sdb_store_get_host("a");
        fail_unless(host != NULL,
@@ -373,7 +374,7 @@ START_TEST(test_cmp_obj)
        };
        char *op_str[] = { "<", "<=", "=", ">=", ">" };
 
-       assert(SDB_STATIC_ARRAY_LEN(tests) == SDB_STATIC_ARRAY_LEN(op_str));
+       ck_assert(SDB_STATIC_ARRAY_LEN(tests) == SDB_STATIC_ARRAY_LEN(op_str));
 
        host = sdb_store_get_host(cmp_obj_data[_i].host);
        fail_unless(host != NULL,
@@ -577,6 +578,9 @@ struct {
                NULL,                              1 },
        { "host.attribute['x1'] IS NULL",
                NULL,                              3 },
+       /* not a boolean so neither TRUE nor FALSE: */
+       { "attribute['k1'] IS TRUE", NULL,     0 },
+       { "attribute['k1'] IS FALSE", NULL,    0 },
        { "attribute['k1'] = 'v1'", NULL,      1 },
        { "attribute['k1'] = 'v1'",
                "name != 'k1'",                    0 },