Skip to content

Commit 0523e78

Browse files
committed
fix(test): update environment variables
1 parent e32de6a commit 0523e78

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

test/integration.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// cloudsync
44
//
55
// Created by Gioele Cantoni on 05/06/25.
6-
// Set CONNECTION_STRING, APIKEY and WEBLITE environment variables before running this test.
6+
// Set INTEGRATION_TEST_OFFLINE_DATABASE_ID and INTEGRATION_TEST_DATABASE_ID environment variables before running this test.
77
//
88

99
#include <stdio.h>
@@ -226,18 +226,13 @@ int test_init (const char *db_path, int init) {
226226

227227
// init network with JSON connection string
228228
char network_init[1024];
229-
const char* conn_str = getenv("CONNECTION_STRING");
230-
const char* apikey = getenv("APIKEY");
231-
const char* project_id = getenv("PROJECT_ID");
232-
const char* org_id = getenv("ORGANIZATION_ID");
233-
const char* database = getenv("DATABASE");
234-
if (!conn_str || !apikey || !project_id || !org_id || !database) {
235-
fprintf(stderr, "Error: CONNECTION_STRING, APIKEY, PROJECT_ID, ORGANIZATION_ID, or DATABASE not set.\n");
229+
const char* test_db_id = getenv("INTEGRATION_TEST_DATABASE_ID");
230+
if (!test_db_id) {
231+
fprintf(stderr, "Error: INTEGRATION_TEST_DATABASE_ID not set.\n");
236232
exit(1);
237233
}
238234
snprintf(network_init, sizeof(network_init),
239-
"SELECT cloudsync_network_init('{\"address\":\"%s\",\"database\":\"%s\",\"projectID\":\"%s\",\"organizationID\":\"%s\",\"apikey\":\"%s\"}');",
240-
conn_str, database, project_id, org_id, apikey);
235+
"SELECT cloudsync_network_init('%s');", test_db_id);
241236
rc = db_exec(db, network_init); RCHECK
242237

243238
rc = db_expect_int(db, "SELECT COUNT(*) as count FROM activities;", 0); RCHECK
@@ -301,18 +296,13 @@ int test_enable_disable(const char *db_path) {
301296

302297
// init network with JSON connection string
303298
char network_init[1024];
304-
const char* conn_str = getenv("CONNECTION_STRING");
305-
const char* apikey = getenv("APIKEY");
306-
const char* project_id = getenv("PROJECT_ID");
307-
const char* org_id = getenv("ORGANIZATION_ID");
308-
const char* database = getenv("DATABASE");
309-
if (!conn_str || !apikey || !project_id || !org_id || !database) {
310-
fprintf(stderr, "Error: CONNECTION_STRING, APIKEY, PROJECT_ID, ORGANIZATION_ID, or DATABASE not set.\n");
299+
const char* test_db_id = getenv("INTEGRATION_TEST_DATABASE_ID");
300+
if (!test_db_id) {
301+
fprintf(stderr, "Error: INTEGRATION_TEST_DATABASE_ID not set.\n");
311302
exit(1);
312303
}
313304
snprintf(network_init, sizeof(network_init),
314-
"SELECT cloudsync_network_init('{\"address\":\"%s\",\"database\":\"%s\",\"projectID\":\"%s\",\"organizationID\":\"%s\",\"apikey\":\"%s\"}');",
315-
conn_str, database, project_id, org_id, apikey);
305+
"SELECT cloudsync_network_init('%s');", test_db_id);
316306
rc = db_exec(db, network_init); RCHECK
317307

318308
rc = db_exec(db, "SELECT cloudsync_network_send_changes();"); RCHECK
@@ -363,16 +353,16 @@ int test_offline_error(const char *db_path) {
363353
rc = db_exec(db, "INSERT INTO test_table (id, value) VALUES (cloudsync_uuid(), 'test1'), (cloudsync_uuid(), 'test2');");
364354
RCHECK
365355

366-
// Initialize network with offline connection string
367-
const char* offline_conn_str = getenv("CONNECTION_STRING_OFFLINE_PROJECT");
368-
if (!offline_conn_str) {
369-
printf("Skipping offline error test: CONNECTION_STRING_OFFLINE_PROJECT not set.\n");
356+
// Initialize network with offline database ID
357+
const char* offline_db_id = getenv("INTEGRATION_TEST_OFFLINE_DATABASE_ID");
358+
if (!offline_db_id) {
359+
printf("Skipping offline error test: INTEGRATION_TEST_OFFLINE_DATABASE_ID not set.\n");
370360
rc = SQLITE_OK;
371361
goto abort_test;
372362
}
373363

374364
char network_init[512];
375-
snprintf(network_init, sizeof(network_init), "SELECT cloudsync_network_init('%s');", offline_conn_str);
365+
snprintf(network_init, sizeof(network_init), "SELECT cloudsync_network_init('%s');", offline_db_id);
376366
rc = db_exec(db, network_init);
377367
RCHECK
378368

0 commit comments

Comments
 (0)