Code

t/: Use ck_assert() instead of assert() in all tests.
[sysdb.git] / t / unit / core / store_json_test.c
index ff6a18edc3ae8f095988129231430b893a0a5b03..b69573c45fde0afd0b90ab5db4402f225eb9ac00 100644 (file)
@@ -32,8 +32,6 @@
 #include "core/store.h"
 #include "testutils.h"
 
-#include <assert.h>
-
 #include <check.h>
 #include <stdlib.h>
 
@@ -124,8 +122,7 @@ verify_json_output(sdb_strbuf_t *buf, const char *expected)
 
 struct {
        struct {
-               sdb_store_matcher_t *(*m)(sdb_store_expr_t *,
-                               sdb_store_expr_t *);
+               sdb_store_matcher_t *(*m)(sdb_store_expr_t *, sdb_store_expr_t *);
                int field;
                sdb_data_t value;
        } filter;
@@ -155,6 +152,9 @@ struct {
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                "\"update_interval\": \"0s\", \"backends\": [], "
                                                "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h1\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []},"
                                                        "{\"name\": \"k3\", \"value\": 42, "
                                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                                "\"update_interval\": \"0s\", \"backends\": []}"
@@ -162,7 +162,12 @@ struct {
                                        "{\"name\": \"m2\", "
                                                "\"timeseries\": false, "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h1\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]}"
                                "]},"
                        "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                "\"update_interval\": \"0s\", \"backends\": [], "
@@ -170,16 +175,29 @@ struct {
                                        "{\"name\": \"m1\", "
                                                "\"timeseries\": false, "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]}"
                                "], "
                                "\"services\": ["
                                        "{\"name\": \"s1\", "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []},"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]},"
                                        "{\"name\": \"s2\", "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                "\"update_interval\": \"0s\", \"backends\": [], "
                                                "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []},"
                                                        "{\"name\": \"k1\", \"value\": 123, "
                                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                                "\"update_interval\": \"0s\", \"backends\": []},"
@@ -215,6 +233,9 @@ struct {
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                "\"update_interval\": \"0s\", \"backends\": [], "
                                                "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []},"
                                                        "{\"name\": \"k1\", \"value\": 123, "
                                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                                "\"update_interval\": \"0s\", \"backends\": []}"
@@ -236,7 +257,12 @@ struct {
                                        "{\"name\": \"m2\", "
                                                "\"timeseries\": false, "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h1\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]}"
                                "]}"
                "]" },
        { { sdb_store_ge_matcher, SDB_FIELD_LAST_UPDATE,
@@ -259,11 +285,19 @@ struct {
                                "\"services\": ["
                                        "{\"name\": \"s1\", "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []},"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]},"
                                        "{\"name\": \"s2\", "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                "\"update_interval\": \"0s\", \"backends\": [], "
                                                "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []},"
                                                        "{\"name\": \"k1\", \"value\": 123, "
                                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                                "\"update_interval\": \"0s\", \"backends\": []},"
@@ -298,6 +332,9 @@ struct {
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                "\"update_interval\": \"0s\", \"backends\": [], "
                                                "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []},"
                                                        "{\"name\": \"k1\", \"value\": 123, "
                                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                                "\"update_interval\": \"0s\", \"backends\": []}"
@@ -319,6 +356,9 @@ struct {
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                "\"update_interval\": \"0s\", \"backends\": [], "
                                                "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h1\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []},"
                                                        "{\"name\": \"k3\", \"value\": 42, "
                                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                                                "\"update_interval\": \"0s\", \"backends\": []}"
@@ -326,7 +366,12 @@ struct {
                                        "{\"name\": \"m2\", "
                                                "\"timeseries\": false, "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h1\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]}"
                                "]},"
                        "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
                                "\"update_interval\": \"0s\", \"backends\": [], "
@@ -334,7 +379,12 @@ struct {
                                        "{\"name\": \"m1\", "
                                                "\"timeseries\": false, "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h2\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]}"
                                "]}"
                "]" },
        { { NULL, 0, SDB_DATA_INIT },
@@ -371,7 +421,12 @@ struct {
                                        "{\"name\": \"m2\", "
                                                "\"timeseries\": false, "
                                                "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
-                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "\"update_interval\": \"0s\", \"backends\": [], "
+                                               "\"attributes\": ["
+                                                       "{\"name\": \"hostname\", \"value\": \"h1\", "
+                                                               "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+                                                               "\"update_interval\": \"0s\", \"backends\": []}"
+                                               "]}"
                                "]}"
                "]" },
        { { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
@@ -409,7 +464,7 @@ START_TEST(test_store_tojson)
        sdb_strbuf_clear(buf);
        f = sdb_store_json_formatter(buf,
                        store_tojson_data[_i].type, SDB_WANT_ARRAY);
-       assert(f);
+       ck_assert(f != NULL);
 
        status = sdb_store_scan(store_tojson_data[_i].type,
                        /* m = */ NULL, filter, store_tojson_data[_i].f, f);