Skip to content

Commit 372a631

Browse files
committed
Test: Improved integration test, with the option to load the extension from the sources
1 parent 21dd681 commit 372a631

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/main.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88

99
#include <stdio.h>
1010
#include <stdlib.h>
11-
#include <utils.h>
11+
#include "utils.h"
1212
#include "sqlite3.h"
1313
#ifdef _WIN32
1414
#include <windows.h>
1515
#else
1616
#include <pthread.h>
1717
#endif
1818

19+
#ifdef CLOUDSYNC_LOAD_FROM_SOURCES
20+
#include "cloudsync.h"
21+
#endif
22+
1923
#define PEERS 5
2024
#define DB_PATH "health-track.sqlite"
2125
#define EXT_PATH "./dist/cloudsync"
@@ -123,13 +127,17 @@ int open_load_ext(const char *db_path, sqlite3 **out_db) {
123127
int rc = sqlite3_open(db_path, &db);
124128
RCHECK
125129

130+
#ifdef CLOUDSYNC_LOAD_FROM_SOURCES
131+
rc = sqlite3_cloudsync_init(db, NULL, NULL);
132+
#else
126133
// enable load extension
127134
rc = sqlite3_enable_load_extension(db, 1);
128135
RCHECK
129136

130137
rc = db_exec(db, "SELECT load_extension('"EXT_PATH"');");
131138
RCHECK
132-
139+
#endif
140+
133141
*out_db = db;
134142
return rc;
135143

@@ -253,6 +261,9 @@ int test_enable_disable(const char *db_path) {
253261
rc = db_exec(db, "SELECT cloudsync_network_send_changes();"); RCHECK
254262
rc = db_exec(db, "SELECT cloudsync_cleanup('*');");
255263

264+
// give the server the time to apply the latest sent changes, it is an async job
265+
sqlite3_sleep(5000);
266+
256267
sqlite3 *db2 = NULL;
257268
rc = open_load_ext(":memory:", &db2); RCHECK
258269
rc = db_init(db2); RCHECK
@@ -275,7 +286,7 @@ int test_enable_disable(const char *db_path) {
275286
ABORT_TEST
276287
}
277288

278-
int version(){
289+
int version(void){
279290
sqlite3 *db = NULL;
280291
int rc = open_load_ext(":memory:", &db);
281292

0 commit comments

Comments
 (0)