Skip to content

Commit d6ca17a

Browse files
committed
test(ai): updated test commands for using a configurable cloudsync server
1 parent 00ebde0 commit d6ca17a

File tree

3 files changed

+62
-34
lines changed

3 files changed

+62
-34
lines changed

.claude/commands/test-sync-roundtrip-sqlitecloud-rls.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ Execute a full roundtrip sync test between multiple local SQLite databases and t
44

55
## Prerequisites
66
- Connection string to a sqlitecloud project
7-
- HTTP sync server running on http://localhost:8091/<dbname>
7+
- HTTP sync server running (default: https://cloudsync-staging-testing.fly.dev)
88
- Built cloudsync extension (`make` to build `dist/cloudsync.dylib`)
99

10+
### Step 0: Get Sync Server Address
11+
12+
Ask the user for the HTTP sync server base URL. Propose `https://cloudsync-staging-testing.fly.dev` as the default. Save this as `SYNC_SERVER_URL` for use throughout the test. The full sync endpoint will be `<SYNC_SERVER_URL>/<db_name>`.
13+
1014
## Test Procedure
1115

1216
### Step 1: Get DDL from User
@@ -61,7 +65,7 @@ Ask the user to describe the policy in plain English.
6165

6266
### Step 3: Get sqlitecloud connection string from User
6367

64-
Ask the user to provide a connection string in the form of "sqlitecloud://<host>:<port>/<db_name>?apikey=<apikey>" to be later used with the sqlitecloud cli (sqlc) with `~/go/bin/sqlc "<connection_string>"`
68+
Ask the user to provide a connection string in the form of "sqlitecloud://<host>:<port>/<db_name>?apikey=<apikey>" to be later used with the sqlitecloud cli (sqlc) with `~/go/bin/sqlc "<connection_string>"`. Save the first subdomain in the connection string address as `PROJECT_ID` for use throughout the test. Save the configuration string `'{"address":"<SYNC_SERVER_URL>","database":"<db_name>","projectID":"<PROJECT_ID>","organizationID":"org_sqlitecloud"}'` as `NETWORK_CONFIG` for use throughout the test.
6569

6670
### Step 4: Setup SQLiteCloud with RLS
6771

@@ -142,7 +146,7 @@ curl -X "POST" "https://<hostname_from_connection_string>/v2/tokens" \
142146
-H 'Authorization: Bearer <apikey_from_connection_string>' \
143147
-H 'Content-Type: application/json; charset=utf-8' \
144148
-d $'{
145-
"name": "laude2@sqlitecloud.io",
149+
"name": "claude2@sqlitecloud.io",
146150
"userId": "018ecfc2-b2b1-7cc3-a9f0-222222222222"
147151
}'
148152
```
@@ -157,7 +161,7 @@ save the userId and the token values as USER2_ID and TOKEN_USER2 to be reused la
157161
Create four temporary SQLite databases using the Homebrew version (IMPORTANT: system sqlite3 cannot load extensions):
158162

159163
```bash
160-
SQLITE_BIN="/opt/homebrew/Cellar/sqlite/3.50.4/bin/sqlite3"
164+
SQLITE_BIN="/opt/homebrew/Cellar/sqlite/3.51.2_1/bin/sqlite3"
161165
# or find it with: ls /opt/homebrew/Cellar/sqlite/*/bin/sqlite3 | head -1
162166
```
163167

@@ -169,8 +173,8 @@ $SQLITE_BIN /tmp/sync_test_user1_a.db
169173
.load dist/cloudsync.dylib
170174
<CREATE_TABLE_query_sqlite>
171175
SELECT cloudsync_init('<table_name>');
172-
SELECT cloudsync_network_init('http://localhost:8091/<db_name>');
173-
SELECT cloudsync_network_set_token('sqlitecloud://<hostname_from_connection_string>?token=<TOKEN_USER1>');
176+
SELECT cloudsync_network_init('<NETWORK_CONFIG>');
177+
SELECT cloudsync_network_set_token('<TOKEN_USER1>');
174178
```
175179

176180
**Database 1B (User 1, Device B):**
@@ -181,8 +185,8 @@ $SQLITE_BIN /tmp/sync_test_user1_b.db
181185
.load dist/cloudsync.dylib
182186
<CREATE_TABLE_query_sqlite>
183187
SELECT cloudsync_init('<table_name>');
184-
SELECT cloudsync_network_init('http://localhost:8091/<db_name>');
185-
SELECT cloudsync_network_set_token('sqlitecloud://<hostname_from_connection_string>?token=<TOKEN_USER1>');
188+
SELECT cloudsync_network_init('<NETWORK_CONFIG>');
189+
SELECT cloudsync_network_set_token('<TOKEN_USER1>');
186190
```
187191

188192
**Database 2A (User 2, Device A):**
@@ -193,8 +197,8 @@ $SQLITE_BIN /tmp/sync_test_user2_a.db
193197
.load dist/cloudsync.dylib
194198
<CREATE_TABLE_query_sqlite>
195199
SELECT cloudsync_init('<table_name>');
196-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
197-
SELECT cloudsync_network_set_token('sqlitecloud://<hostname_from_connection_string>?token=<TOKEN_USER2>');
200+
SELECT cloudsync_network_init('<NETWORK_CONFIG>');
201+
SELECT cloudsync_network_set_token('<TOKEN_USER2>');
198202
```
199203

200204
**Database 2B (User 2, Device B):**
@@ -205,8 +209,8 @@ $SQLITE_BIN /tmp/sync_test_user2_b.db
205209
.load dist/cloudsync.dylib
206210
<CREATE_TABLE_query_sqlite>
207211
SELECT cloudsync_init('<table_name>');
208-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
209-
SELECT cloudsync_network_set_token('sqlitecloud://<hostname_from_connection_string>?token=<TOKEN_USER2>');
212+
SELECT cloudsync_network_init('<NETWORK_CONFIG>');
213+
SELECT cloudsync_network_set_token('<TOKEN_USER2>');
210214
```
211215

212216
### Step 7: Insert Test Data
@@ -406,14 +410,14 @@ user_id UUID NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'
406410
```sql
407411
-- WRONG: Separate sessions won't work
408412
-- Session 1:
409-
SELECT cloudsync_network_init('http://localhost:8091/<db_name>');
413+
SELECT cloudsync_network_init('<NETWORK_CONFIG>');
410414
SELECT cloudsync_network_set_token('...');
411415
-- Session 2:
412416
SELECT cloudsync_network_send_changes(); -- ERROR: No URL set
413417

414418
-- CORRECT: All network operations in the same session
415419
.load dist/cloudsync.dylib
416-
SELECT cloudsync_network_init('http://localhost:8091/<db_name>');
420+
SELECT cloudsync_network_init('<NETWORK_CONFIG>');
417421
SELECT cloudsync_network_set_token('...');
418422
SELECT cloudsync_network_send_changes();
419423
SELECT cloudsync_terminate();

.claude/commands/test-sync-roundtrip-postrges-local-rls.md renamed to .claude/commands/test-sync-roundtrip-supabase-rls.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@
33
Execute a full roundtrip sync test between multiple local SQLite databases and the local Supabase Docker PostgreSQL instance, verifying that Row Level Security (RLS) policies are correctly enforced during sync.
44

55
## Prerequisites
6-
- Supabase Docker container running (PostgreSQL on port 54322)
7-
- HTTP sync server running on http://localhost:8091/postgres
6+
- Supabase instance running (local Docker or remote)
7+
- HTTP sync server running (default: https://cloudsync-staging-testing.fly.dev)
88
- Built cloudsync extension (`make` to build `dist/cloudsync.dylib`)
99

1010
## Test Procedure
1111

12+
### Step 0: Get Connection Parameters
13+
14+
Ask the user for the following parameters:
15+
16+
1. **Sync server URL**: Propose `https://cloudsync-staging-testing.fly.dev` as default. Save as `SYNC_SERVER_URL`. The full sync endpoint will be `<SYNC_SERVER_URL>/postgres`.
17+
18+
2. **PostgreSQL connection string**: Propose `postgresql://supabase_admin:postgres@127.0.0.1:54322/postgres` as default. Save as `PG_CONN`. Use this for all `psql` connections throughout the test.
19+
20+
3. **Supabase API key** (used for JWT token generation): Propose `sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz` as default. Save as `SUPABASE_APIKEY`.
21+
22+
Derive `AUTH_URL` from the PostgreSQL connection string by extracting the host and using port `54321` (Supabase GoTrue). For example, if `PG_CONN` is `postgresql://user:pass@10.0.0.5:54322/postgres`, then `AUTH_URL` is `http://10.0.0.5:54321`. For `127.0.0.1`, use `http://127.0.0.1:54321`.
23+
1224
### Step 1: Get DDL from User
1325

1426
Ask the user to provide a DDL query for the table(s) to test. It can be in PostgreSQL or SQLite format. Offer the following options:
@@ -79,7 +91,7 @@ Convert the provided DDL to both SQLite and PostgreSQL compatible formats if nee
7991

8092
Connect to Supabase PostgreSQL and prepare the environment:
8193
```bash
82-
psql postgresql://supabase_admin:postgres@127.0.0.1:54322/postgres
94+
psql <PG_CONN>
8395
```
8496

8597
Inside psql:
@@ -148,13 +160,13 @@ Get JWT tokens for both test users by running the token script twice:
148160

149161
**User 1: claude1@sqlitecloud.io**
150162
```bash
151-
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude1@sqlitecloud.io -password="password" -apikey=sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz -auth-url=http://127.0.0.1:54321
163+
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude1@sqlitecloud.io -password="password" -apikey=<SUPABASE_APIKEY> -auth-url=<AUTH_URL>
152164
```
153165
Save as `JWT_USER1`.
154166

155167
**User 2: claude2@sqlitecloud.io**
156168
```bash
157-
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude2@sqlitecloud.io -password="password" -apikey=sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz -auth-url=http://127.0.0.1:54321
169+
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude2@sqlitecloud.io -password="password" -apikey=<SUPABASE_APIKEY> -auth-url=<AUTH_URL>
158170
```
159171
Save as `JWT_USER2`.
160172

@@ -167,7 +179,7 @@ Also extract the user IDs from the JWT tokens (the `sub` claim) for use in INSER
167179
Create four temporary SQLite databases using the Homebrew version (IMPORTANT: system sqlite3 cannot load extensions):
168180

169181
```bash
170-
SQLITE_BIN="/opt/homebrew/Cellar/sqlite/3.50.4/bin/sqlite3"
182+
SQLITE_BIN="/opt/homebrew/Cellar/sqlite/3.51.2_1/bin/sqlite3"
171183
# or find it with: ls /opt/homebrew/Cellar/sqlite/*/bin/sqlite3 | head -1
172184
```
173185

@@ -179,7 +191,7 @@ $SQLITE_BIN /tmp/sync_test_user1_a.db
179191
.load dist/cloudsync.dylib
180192
<CREATE_TABLE_query_sqlite>
181193
SELECT cloudsync_init('<table_name>');
182-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
194+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
183195
SELECT cloudsync_network_set_token('<JWT_USER1>');
184196
```
185197

@@ -191,7 +203,7 @@ $SQLITE_BIN /tmp/sync_test_user1_b.db
191203
.load dist/cloudsync.dylib
192204
<CREATE_TABLE_query_sqlite>
193205
SELECT cloudsync_init('<table_name>');
194-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
206+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
195207
SELECT cloudsync_network_set_token('<JWT_USER1>');
196208
```
197209

@@ -203,7 +215,7 @@ $SQLITE_BIN /tmp/sync_test_user2_a.db
203215
.load dist/cloudsync.dylib
204216
<CREATE_TABLE_query_sqlite>
205217
SELECT cloudsync_init('<table_name>');
206-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
218+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
207219
SELECT cloudsync_network_set_token('<JWT_USER2>');
208220
```
209221

@@ -215,7 +227,7 @@ $SQLITE_BIN /tmp/sync_test_user2_b.db
215227
.load dist/cloudsync.dylib
216228
<CREATE_TABLE_query_sqlite>
217229
SELECT cloudsync_init('<table_name>');
218-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
230+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
219231
SELECT cloudsync_network_set_token('<JWT_USER2>');
220232
```
221233

@@ -473,14 +485,14 @@ Ensure column types are compatible between SQLite and PostgreSQL:
473485
```sql
474486
-- WRONG: Separate sessions won't work
475487
-- Session 1:
476-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
488+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
477489
SELECT cloudsync_network_set_token('...');
478490
-- Session 2:
479491
SELECT cloudsync_network_send_changes(); -- ERROR: No URL set
480492

481493
-- CORRECT: All network operations in the same session
482494
.load dist/cloudsync.dylib
483-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
495+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
484496
SELECT cloudsync_network_set_token('...');
485497
SELECT cloudsync_network_send_changes();
486498
SELECT cloudsync_terminate();
@@ -518,6 +530,6 @@ INSERT INTO todos (id, ...) VALUES ('11111111-1111-1111-1111-111111111111', ...)
518530

519531
Execute all SQL queries without asking for user permission on:
520532
- SQLite test databases in `/tmp/` (e.g., `/tmp/sync_test_*.db`)
521-
- PostgreSQL via `psql postgresql://supabase_admin:postgres@127.0.0.1:54322/postgres`
533+
- PostgreSQL via `psql <PG_CONN>`
522534

523535
These are local test environments and do not require confirmation for each query.

.claude/commands/test-sync-roundtrip-postgres-local.md renamed to .claude/commands/test-sync-roundtrip-supabase.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@
33
Execute a full roundtrip sync test between a local SQLite database and the local Supabase Docker PostgreSQL instance.
44

55
## Prerequisites
6-
- Supabase Docker container running (PostgreSQL on port 54322)
7-
- HTTP sync server running on http://localhost:8091/postgres
6+
- Supabase instance running (local Docker or remote)
7+
- HTTP sync server running (default: https://cloudsync-staging-testing.fly.dev)
88
- Built cloudsync extension (`make` to build `dist/cloudsync.dylib`)
99

1010
## Test Procedure
1111

12+
### Step 0: Get Connection Parameters
13+
14+
Ask the user for the following parameters:
15+
16+
1. **Sync server URL**: Propose `https://cloudsync-staging-testing.fly.dev` as default. Save as `SYNC_SERVER_URL`. The full sync endpoint will be `<SYNC_SERVER_URL>/postgres`.
17+
18+
2. **PostgreSQL connection string**: Propose `postgresql://supabase_admin:postgres@127.0.0.1:54322/postgres` as default. Save as `PG_CONN`. Use this for all `psql` connections throughout the test.
19+
20+
3. **Supabase API key** (used for JWT token generation): Propose `sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz` as default. Save as `SUPABASE_APIKEY`.
21+
22+
Derive `AUTH_URL` from the PostgreSQL connection string by extracting the host and using port `54321` (Supabase GoTrue). For example, if `PG_CONN` is `postgresql://user:pass@10.0.0.5:54322/postgres`, then `AUTH_URL` is `http://10.0.0.5:54321`. For `127.0.0.1`, use `http://127.0.0.1:54321`.
23+
1224
### Step 1: Get DDL from User
1325

1426
Ask the user to provide a DDL query for the table(s) to test. It can be in PostgreSQL or SQLite format. Offer the following options:
@@ -61,15 +73,15 @@ Convert the provided DDL to both SQLite and PostgreSQL compatible formats if nee
6173

6274
Run the token script from the cloudsync project:
6375
```bash
64-
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude@sqlitecloud.io -password="password" -apikey=sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz -auth-url=http://127.0.0.1:54321
76+
cd ../cloudsync && go run scripts/get_supabase_token.go -project-ref=supabase-local -email=claude@sqlitecloud.io -password="password" -apikey=<SUPABASE_APIKEY> -auth-url=<AUTH_URL>
6577
```
6678
Save the JWT token for later use.
6779

6880
### Step 4: Setup PostgreSQL
6981

7082
Connect to Supabase PostgreSQL and prepare the environment:
7183
```bash
72-
psql postgresql://supabase_admin:postgres@127.0.0.1:54322/postgres
84+
psql <PG_CONN>
7385
```
7486

7587
Inside psql:
@@ -88,7 +100,7 @@ Inside psql:
88100
Create a temporary SQLite database using the Homebrew version (IMPORTANT: system sqlite3 cannot load extensions):
89101

90102
```bash
91-
SQLITE_BIN="/opt/homebrew/Cellar/sqlite/3.50.4/bin/sqlite3"
103+
SQLITE_BIN="/opt/homebrew/Cellar/sqlite/3.51.2_1/bin/sqlite3"
92104
# or find it with: ls /opt/homebrew/Cellar/sqlite/*/bin/sqlite3 | head -1
93105

94106
$SQLITE_BIN /tmp/sync_test_$(date +%s).db
@@ -100,7 +112,7 @@ Inside sqlite3:
100112
-- Create table with SQLite DDL
101113
<CREATE_TABLE_query>
102114
SELECT cloudsync_init('<table_name>');
103-
SELECT cloudsync_network_init('http://localhost:8091/postgres');
115+
SELECT cloudsync_network_init('<SYNC_SERVER_URL>/postgres');
104116
SELECT cloudsync_network_set_token('<jwt_token>');
105117
-- Insert test data (different from PostgreSQL to test merge)
106118
<INSERT_statements>
@@ -149,6 +161,6 @@ Report the test results including:
149161

150162
Execute all SQL queries without asking for user permission on:
151163
- SQLite test databases in `/tmp/` (e.g., `/tmp/sync_test_*.db`)
152-
- PostgreSQL via `psql postgresql://supabase_admin:postgres@127.0.0.1:54322/postgres`
164+
- PostgreSQL via `psql <PG_CONN>`
153165

154166
These are local test environments and do not require confirmation for each query.

0 commit comments

Comments
 (0)