feat(sync): round trip cloud snapshots
This commit is contained in:
@@ -111,19 +111,20 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_round_trip_preserves_kebab_case_variants() {
|
||||
fn json_round_trip_preserves_kebab_case_variants() -> Result<(), serde_json::Error> {
|
||||
let mut settings = AppearanceSettings::default();
|
||||
settings.set_wallpaper(WallpaperTheme::Mint);
|
||||
settings.set_theme_mode(ThemeMode::Light);
|
||||
settings.set_reduce_motion(true);
|
||||
settings.set_translucency_pct(60);
|
||||
|
||||
let json = serde_json::to_string(&settings).unwrap();
|
||||
let json = serde_json::to_string(&settings)?;
|
||||
assert!(json.contains("\"wallpaper\":\"mint\""));
|
||||
assert!(json.contains("\"theme_mode\":\"light\""));
|
||||
assert!(json.contains("\"translucency_pct\":60"));
|
||||
|
||||
let restored: AppearanceSettings = serde_json::from_str(&json).unwrap();
|
||||
let restored: AppearanceSettings = serde_json::from_str(&json)?;
|
||||
assert_eq!(restored, settings);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,32 @@ impl BookmarkEntry {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn restore(
|
||||
id: BookmarkId,
|
||||
profile_id: ProfileId,
|
||||
space_id: SpaceId,
|
||||
collection_name: impl Into<String>,
|
||||
title: impl Into<String>,
|
||||
url: UrlText,
|
||||
added_at: SystemTime,
|
||||
) -> Result<Self, DomainError> {
|
||||
let collection_name = non_empty_text("bookmark collection", collection_name.into())?;
|
||||
let title = non_empty_text("bookmark title", title.into())?;
|
||||
|
||||
Ok(Self {
|
||||
id,
|
||||
profile_id,
|
||||
space_id,
|
||||
collection_name,
|
||||
title,
|
||||
url,
|
||||
tags: Vec::new(),
|
||||
note: None,
|
||||
thumbnail_key: None,
|
||||
added_at,
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn id(&self) -> &BookmarkId {
|
||||
&self.id
|
||||
|
||||
Reference in New Issue
Block a user