| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
use crate::models::{ |
| 10 |
Attachment, DailyNote, Email, Event, Milestone, MonthlyGoal, MonthlyReflection, Project, |
| 11 |
SavedView, SyncAccount, Task, TimeSession, WeeklyReview, |
| 12 |
}; |
| 13 |
use crate::Contact; |
| 14 |
|
| 15 |
|
| 16 |
#[derive(Debug, Default)] |
| 17 |
pub struct RestoreResult { |
| 18 |
|
| 19 |
pub projects_restored: usize, |
| 20 |
|
| 21 |
pub tasks_restored: usize, |
| 22 |
|
| 23 |
pub events_restored: usize, |
| 24 |
|
| 25 |
pub emails_restored: usize, |
| 26 |
|
| 27 |
pub subtasks_restored: usize, |
| 28 |
|
| 29 |
pub status_tokens_restored: usize, |
| 30 |
|
| 31 |
pub annotations_restored: usize, |
| 32 |
|
| 33 |
pub contacts_restored: usize, |
| 34 |
|
| 35 |
pub time_sessions_restored: usize, |
| 36 |
|
| 37 |
pub milestones_restored: usize, |
| 38 |
|
| 39 |
pub daily_notes_restored: usize, |
| 40 |
|
| 41 |
pub attachments_restored: usize, |
| 42 |
|
| 43 |
pub sync_accounts_restored: usize, |
| 44 |
|
| 45 |
pub saved_views_restored: usize, |
| 46 |
|
| 47 |
pub weekly_reviews_restored: usize, |
| 48 |
|
| 49 |
pub monthly_goals_restored: usize, |
| 50 |
|
| 51 |
pub monthly_reflections_restored: usize, |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
pub struct RestoreInput { |
| 56 |
pub projects: Vec<Project>, |
| 57 |
pub tasks: Vec<Task>, |
| 58 |
pub events: Vec<Event>, |
| 59 |
pub emails: Vec<Email>, |
| 60 |
pub contacts: Vec<Contact>, |
| 61 |
pub time_sessions: Vec<TimeSession>, |
| 62 |
pub milestones: Vec<Milestone>, |
| 63 |
pub daily_notes: Vec<DailyNote>, |
| 64 |
pub attachments: Vec<Attachment>, |
| 65 |
pub sync_accounts: Vec<SyncAccount>, |
| 66 |
pub saved_views: Vec<SavedView>, |
| 67 |
pub weekly_reviews: Vec<WeeklyReview>, |
| 68 |
pub monthly_goals: Vec<MonthlyGoal>, |
| 69 |
pub monthly_reflections: Vec<MonthlyReflection>, |
| 70 |
} |
| 71 |
|
| 72 |
#[cfg(test)] |
| 73 |
mod tests { |
| 74 |
use super::*; |
| 75 |
|
| 76 |
#[test] |
| 77 |
fn restore_result_default_all_zeros() { |
| 78 |
let r = RestoreResult::default(); |
| 79 |
assert_eq!(r.projects_restored, 0); |
| 80 |
assert_eq!(r.tasks_restored, 0); |
| 81 |
assert_eq!(r.events_restored, 0); |
| 82 |
assert_eq!(r.emails_restored, 0); |
| 83 |
} |
| 84 |
|
| 85 |
#[test] |
| 86 |
fn restore_input_accepts_empty_vecs() { |
| 87 |
let input = RestoreInput { |
| 88 |
projects: vec![], |
| 89 |
tasks: vec![], |
| 90 |
events: vec![], |
| 91 |
emails: vec![], |
| 92 |
contacts: vec![], |
| 93 |
time_sessions: vec![], |
| 94 |
milestones: vec![], |
| 95 |
daily_notes: vec![], |
| 96 |
attachments: vec![], |
| 97 |
sync_accounts: vec![], |
| 98 |
saved_views: vec![], |
| 99 |
weekly_reviews: vec![], |
| 100 |
monthly_goals: vec![], |
| 101 |
monthly_reflections: vec![], |
| 102 |
}; |
| 103 |
assert!(input.projects.is_empty()); |
| 104 |
assert!(input.tasks.is_empty()); |
| 105 |
assert!(input.events.is_empty()); |
| 106 |
assert!(input.emails.is_empty()); |
| 107 |
assert!(input.contacts.is_empty()); |
| 108 |
assert!(input.time_sessions.is_empty()); |
| 109 |
assert!(input.milestones.is_empty()); |
| 110 |
assert!(input.daily_notes.is_empty()); |
| 111 |
assert!(input.attachments.is_empty()); |
| 112 |
assert!(input.sync_accounts.is_empty()); |
| 113 |
} |
| 114 |
} |
| 115 |
|