Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3506637
D4247.id13710.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4247.id13710.diff
View Options
diff --git a/services/commtest/tests/backup/add_attachments.rs b/services/commtest/tests/backup/add_attachments.rs
new file mode 100644
--- /dev/null
+++ b/services/commtest/tests/backup/add_attachments.rs
@@ -0,0 +1,53 @@
+#[path = "./backup_utils.rs"]
+mod backup_utils;
+#[path = "../lib/tools.rs"]
+mod tools;
+
+use crate::backup_utils::{proto::AddAttachmentsRequest, BackupServiceClient};
+
+use tonic::Request;
+
+use crate::backup_utils::BackupData;
+use crate::tools::{Error, ATTACHMENT_DELIMITER};
+
+// log_index = None means that we add attachments to the backup
+// log_index = Some(x) means that we add attachments to a specific log
+pub async fn run(
+ client: &mut BackupServiceClient<tonic::transport::Channel>,
+ backup_data: &BackupData,
+ log_index: Option<usize>,
+) -> Result<(), Error> {
+ let cloned_user_id = backup_data.user_id.clone();
+ let cloned_backup_id = backup_data.backup_item.id.clone();
+ let log_id: String = match log_index {
+ Some(index) => {
+ let log_id = backup_data.log_items[index].id.clone();
+ println!("add attachments for log {}/{}", index, log_id);
+ log_id
+ },
+ None => {
+ println!("add attachments for backup");
+ String::new()
+ },
+ };
+
+ let holders: String = match log_index {
+ Some(log_index) => backup_data.log_items[log_index]
+ .attachments_holders
+ .join(&ATTACHMENT_DELIMITER.to_string()[..]),
+ None => backup_data
+ .backup_item
+ .attachments_holders
+ .join(&ATTACHMENT_DELIMITER.to_string()[..]),
+ };
+
+ client
+ .add_attachments(Request::new(AddAttachmentsRequest {
+ user_id: cloned_user_id,
+ backup_id: cloned_backup_id,
+ log_id,
+ holders,
+ }))
+ .await?;
+ Ok(())
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 5:36 PM (19 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2685897
Default Alt Text
D4247.id13710.diff (1 KB)
Attached To
Mode
D4247: [services] Tests - Add add_attachments
Attached
Detach File
Event Timeline
Log In to Comment