MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / document_roundtrip

Function document_roundtrip

nodedb/tests/sql_backup_restore_wire.rs:94–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92
93#[tokio::test]
94async fn document_roundtrip() {
95 let server = TestServer::start().await;
96 server
97 .exec(
98 "CREATE COLLECTION wire_docs \
99 (id TEXT PRIMARY KEY, content TEXT) WITH (engine='document_strict')",
100 )
101 .await
102 .ok();
103 server
104 .exec("INSERT INTO wire_docs (id, content) VALUES ('a','alpha')")
105 .await
106 .expect("insert a");
107 server
108 .exec("INSERT INTO wire_docs (id, content) VALUES ('b','beta')")
109 .await
110 .expect("insert b");
111
112 let bytes = drain_backup(&server, TENANT).await.expect("BACKUP");
113
114 // Restore over the *same* server is a valid sanity check — restore is
115 // idempotent at the engine level (PointPut overwrites).
116 push_restore(&server, TENANT, bytes, false)
117 .await
118 .expect("RESTORE");
119
120 let rows = server
121 .query_text("SELECT content FROM wire_docs WHERE id='a'")
122 .await
123 .expect("post-restore SELECT");
124 assert!(
125 rows.iter().any(|r| r.contains("alpha")),
126 "expected post-restore rows to contain 'alpha', got: {rows:?}"
127 );
128}
129
130// ────────────────────────────────────────────────────────────────────
131// Dry run — validates envelope, must not mutate state.

Callers

nothing calls this directly

Calls 6

query_textMethod · 0.80
drain_backupFunction · 0.70
push_restoreFunction · 0.70
okMethod · 0.45
execMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected