@@ -286,6 +286,30 @@ SELECT cloudsync_init('smoke_tbl', 'CLS', true) AS _init_site_id2 \gset
286286SELECT cloudsync_init(' smoke_tbl' , ' CLS' , true) AS _init_site_id3 \gset
287287\echo ' [PASS] double init no-op'
288288
289+ -- 'Test payload roundtrip to another database'
290+ SELECT md5(COALESCE(string_agg(id || ' :' || COALESCE(val, ' ' ), ' ,' ORDER BY id), ' ' )) AS smoke_hash
291+ FROM smoke_tbl \gset
292+ SELECT encode(cloudsync_payload_encode(tbl, pk, col_name, col_value, col_version, db_version, site_id, cl, seq), ' hex' ) AS payload_hex
293+ FROM cloudsync_changes
294+ WHERE site_id = cloudsync_siteid() \gset
295+ DROP DATABASE IF EXISTS cloudsync_test_2;
296+ CREATE DATABASE cloudsync_test_2 ;
297+ \connect cloudsync_test_2
298+ CREATE EXTENSION cloudsync;
299+ DROP TABLE IF EXISTS smoke_tbl;
300+ CREATE TABLE smoke_tbl (id TEXT PRIMARY KEY , val TEXT );
301+ SELECT cloudsync_init(' smoke_tbl' , ' CLS' , true) AS _init_site_id_b \gset
302+ SELECT cloudsync_payload_apply(decode(:' payload_hex' , ' hex' )) AS _apply_ok \gset
303+ SELECT md5(COALESCE(string_agg(id || ' :' || COALESCE(val, ' ' ), ' ,' ORDER BY id), ' ' )) AS smoke_hash_b
304+ FROM smoke_tbl \gset
305+ SELECT (:' smoke_hash' = :' smoke_hash_b' ) AS payload_roundtrip_ok \gset
306+ \if :payload_roundtrip_ok
307+ \echo ' [PASS] Test payload roundtrip to another database'
308+ \else
309+ \echo ' [FAIL] Test payload roundtrip to another database'
310+ SELECT (:fail::int + 1 ) AS fail \gset
311+ \endif
312+
289313-- 'Test summary'
290314\echo ' \n Test summary:'
291315\echo - Failures: :fail
0 commit comments