]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Add checking correctness of uc_update in tests
authorBarbara Kaczorowska <bkjg@google.com>
Tue, 18 Aug 2020 15:40:25 +0000 (15:40 +0000)
committerBarbara Kaczorowska <bkjg@google.com>
Wed, 19 Aug 2020 07:42:08 +0000 (07:42 +0000)
src/daemon/utils_cache_test.c

index 10ee619aadf34de48169961f82365bdd758615e1..1f2cbf0d7e65555fd6d25298a7f92f8379d24f60 100644 (file)
@@ -30,7 +30,6 @@
 #include "testing.h"
 #include "utils_cache.h"
 
-/* TODO(bkjg): change all fams to pointers */
 static metric_family_t *create_metric_family_test1(char *name) {
   metric_family_t *fam = calloc(1, sizeof(metric_family_t));
 
@@ -60,6 +59,7 @@ static metric_family_t *create_metric_family_test1(char *name) {
   return fam;
 }
 
+/* TODO(bkjg): write more test cases */
 DEF_TEST(uc_update) {
   struct {
     int want_get;
@@ -104,6 +104,10 @@ DEF_TEST(uc_update) {
     /* TODO(bkjg): check if it was it updated for sure, for example: check if we
      * can find it in the avl tree or so */
     EXPECT_EQ_INT(cases[i].want_get, uc_update(cases[i].fam));
+    EXPECT_EQ_UINT64(
+        cases[i].fam->metric.ptr[cases[i].fam->metric.num - 1].time,
+        uc_get_last_time(cases[i].fam->name));
+    EXPECT_EQ_UINT64(cdtime(), uc_get_last_update(cases[i].fam->name));
 
     CHECK_ZERO(metric_family_metric_reset(cases[i].fam));
     free(cases[i].fam);