Pause sync for private profiles
This commit is contained in:
@@ -17,6 +17,7 @@ fn new_private_profile_command_creates_private_profile() -> Result<(), Box<dyn E
|
|||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(profile.kind(), &ProfileKind::Private);
|
assert_eq!(profile.kind(), &ProfileKind::Private);
|
||||||
|
assert_eq!(profile.sync_policy(), ProfileSyncPolicy::Paused);
|
||||||
assert_eq!(&snapshot.active_profile_id, profile.id());
|
assert_eq!(&snapshot.active_profile_id, profile.id());
|
||||||
assert_eq!(snapshot.active_profile_name, "Private");
|
assert_eq!(snapshot.active_profile_name, "Private");
|
||||||
assert_eq!(snapshot.command_query, "");
|
assert_eq!(snapshot.command_query, "");
|
||||||
@@ -46,6 +47,21 @@ fn private_profiles_do_not_record_history() -> Result<(), Box<dyn Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn private_profile_starts_with_sync_paused() -> Result<(), Box<dyn Error>> {
|
||||||
|
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||||
|
let private_profile_id = core.create_profile("Private", 0x807d72, ProfileKind::Private)?;
|
||||||
|
let snapshot = core.snapshot()?;
|
||||||
|
let Some(private_profile) =
|
||||||
|
snapshot.profiles.iter().find(|profile| profile.id() == &private_profile_id)
|
||||||
|
else {
|
||||||
|
return Err("missing private profile".into());
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(private_profile.sync_policy(), ProfileSyncPolicy::Paused);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn profile_sync_policy_can_pause_one_profile() -> Result<(), Box<dyn Error>> {
|
fn profile_sync_policy_can_pause_one_profile() -> Result<(), Box<dyn Error>> {
|
||||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||||
|
|||||||
@@ -52,13 +52,18 @@ pub struct Profile {
|
|||||||
impl Profile {
|
impl Profile {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(name: impl Into<String>, color_hex: u32, kind: ProfileKind) -> Self {
|
pub fn new(name: impl Into<String>, color_hex: u32, kind: ProfileKind) -> Self {
|
||||||
|
let sync_policy = match kind {
|
||||||
|
ProfileKind::Standard => ProfileSyncPolicy::Enabled,
|
||||||
|
ProfileKind::Private => ProfileSyncPolicy::Paused,
|
||||||
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id: ProfileId::new(),
|
id: ProfileId::new(),
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
color_hex,
|
color_hex,
|
||||||
kind,
|
kind,
|
||||||
download_policy: DownloadPolicy::ask_every_time(),
|
download_policy: DownloadPolicy::ask_every_time(),
|
||||||
sync_policy: ProfileSyncPolicy::default(),
|
sync_policy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user