summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-06-28 10:13:24 +0300
committerGitHub <noreply@github.com>2022-06-28 10:13:24 +0300
commit0761496432a9b3057997c0de9410be49d3d70eb3 (patch)
tree11643aea94b2a021edeae52c8c409e3d263993bf /daemon
parent495b5dba4f27753b156d328502ff6698ba1919db (diff)
Add more sqlite unittests (#13227)
Diffstat (limited to 'daemon')
-rw-r--r--daemon/unit_test.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/daemon/unit_test.c b/daemon/unit_test.c
index 5b4213ff53..70fe388e46 100644
--- a/daemon/unit_test.c
+++ b/daemon/unit_test.c
@@ -1532,8 +1532,66 @@ int test_sqlite(void) {
fprintf(stderr,"Failed to test SQLite: Update with LIMIT failed\n");
return 1;
}
+
+ BUFFER *sql = buffer_create(ACLK_SYNC_QUERY_SIZE);
+ char *uuid_str = "0000_000";
+
+ buffer_sprintf(sql, TABLE_ACLK_CHART, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ buffer_flush(sql);
+ if (rc != SQLITE_OK)
+ goto error;
+
+ buffer_sprintf(sql, TABLE_ACLK_CHART_PAYLOAD, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ buffer_flush(sql);
+ if (rc != SQLITE_OK)
+ goto error;
+
+ buffer_sprintf(sql, TABLE_ACLK_CHART_LATEST, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ if (rc != SQLITE_OK)
+ goto error;
+ buffer_flush(sql);
+
+ buffer_sprintf(sql, INDEX_ACLK_CHART, uuid_str, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ if (rc != SQLITE_OK)
+ goto error;
+ buffer_flush(sql);
+
+ buffer_sprintf(sql, INDEX_ACLK_CHART_LATEST, uuid_str, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ if (rc != SQLITE_OK)
+ goto error;
+ buffer_flush(sql);
+
+ buffer_sprintf(sql, TRIGGER_ACLK_CHART_PAYLOAD, uuid_str, uuid_str, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ if (rc != SQLITE_OK)
+ goto error;
+ buffer_flush(sql);
+
+ buffer_sprintf(sql, TABLE_ACLK_ALERT, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ if (rc != SQLITE_OK)
+ goto error;
+ buffer_flush(sql);
+
+ buffer_sprintf(sql, INDEX_ACLK_ALERT, uuid_str, uuid_str);
+ rc = sqlite3_exec(db_meta, buffer_tostring(sql), 0, 0, NULL);
+ if (rc != SQLITE_OK)
+ goto error;
+ buffer_flush(sql);
+
+ buffer_free(sql);
fprintf(stderr,"SQLite is OK\n");
return 0;
+error:
+ fprintf(stderr,"SQLite statement failed: %s\n", buffer_tostring(sql));
+ buffer_free(sql);
+ fprintf(stderr,"SQLite tests failed\n");
+ return 1;
}