coven_database/store/store_session/test_support/
blob.rs1use super::*;
2
3impl StoreDatabase {
4 pub async fn row_blob_bindings_for_test(&self) -> Result<String, DbError> {
5 self.call_store(|session| session.row_blob_bindings_for_test())
6 .await
7 }
8
9 pub async fn replace_blob_row_stamp_for_test(
10 &self,
11 table: &str,
12 row_id: &str,
13 stamp: &str,
14 ) -> Result<(), DbError> {
15 let table = table.to_string();
16 let row_id = row_id.to_string();
17 let stamp = stamp.to_string();
18 self.call_store(move |session| {
19 session.replace_blob_row_stamp_for_test(&table, &row_id, &stamp)
20 })
21 .await
22 }
23
24 pub async fn replace_blob_row_facts_for_test(
25 &self,
26 table: &str,
27 row_id: &str,
28 size: i64,
29 hash: &str,
30 stamp: &str,
31 ) -> Result<(), DbError> {
32 let table = table.to_string();
33 let row_id = row_id.to_string();
34 let hash = hash.to_string();
35 let stamp = stamp.to_string();
36 self.call_store(move |session| {
37 session.replace_blob_row_facts_for_test(&table, &row_id, size, &hash, &stamp)
38 })
39 .await
40 }
41
42 pub async fn complete_note_blob_transition_to_remote_for_test(
43 &self,
44 reference: coven_protocol::blob::RowBlobRef,
45 note_id: String,
46 ) -> Result<(), DbError> {
47 self.call_store(move |session| {
48 session.complete_note_blob_transition_to_remote_for_test(&reference, ¬e_id)
49 })
50 .await
51 }
52
53 pub async fn plant_blob_namespace_collision_for_test(
54 &self,
55 id: &str,
56 local_hash: &str,
57 remote_hash: &str,
58 ) -> Result<(), DbError> {
59 let id = id.to_string();
60 let local_hash = local_hash.to_string();
61 let remote_hash = remote_hash.to_string();
62 self.call_store(move |session| {
63 session.plant_blob_namespace_collision_for_test(&id, &local_hash, &remote_hash)
64 })
65 .await
66 }
67
68 pub async fn plant_note_cover_blob_row_for_test(
69 &self,
70 id: &str,
71 note_id: &str,
72 size: i64,
73 hash: &str,
74 ) -> Result<(), DbError> {
75 let id = id.to_string();
76 let note_id = note_id.to_string();
77 let hash = hash.to_string();
78 self.call_store(move |session| {
79 session.plant_note_cover_blob_row_for_test(&id, ¬e_id, size, &hash)
80 })
81 .await
82 }
83}
84
85impl StoreSession<'_> {
86 fn row_blob_bindings_for_test(&self) -> Result<String, DbError> {
87 self.conn
88 .query_row(
89 "SELECT json_group_array(json_array(
90 table_name, row_id, column_name, row_stamp, audience_authority, remote_object_id))
91 FROM (SELECT * FROM row_blob_locators
92 ORDER BY table_name, row_id, column_name, row_stamp)",
93 [],
94 |row| row.get(0),
95 )
96 .map_err(DbError::from)
97 }
98}