feat(m1): add Tier and NotificationLevel to config
This commit is contained in:
parent
5216549d0a
commit
c94fc58296
1 changed files with 52 additions and 2 deletions
|
|
@ -11,6 +11,22 @@ pub enum SourceOs {
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum Tier {
|
||||||
|
Free,
|
||||||
|
Paid,
|
||||||
|
Premium,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum NotificationLevel {
|
||||||
|
Off,
|
||||||
|
BadgeOnly,
|
||||||
|
BadgeAndToast,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct MigrationConfig {
|
pub struct MigrationConfig {
|
||||||
pub source_os: SourceOs,
|
pub source_os: SourceOs,
|
||||||
|
|
@ -37,14 +53,14 @@ impl Default for OllamaConfig {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct DisplayConfig {
|
pub struct DisplayConfig {
|
||||||
pub show_notifications: bool,
|
pub notification_level: NotificationLevel,
|
||||||
pub quiet_mode: bool,
|
pub quiet_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for DisplayConfig {
|
impl Default for DisplayConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
show_notifications: true,
|
notification_level: NotificationLevel::BadgeAndToast,
|
||||||
quiet_mode: false,
|
quiet_mode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +71,7 @@ pub struct RobinConfig {
|
||||||
pub migration: Option<MigrationConfig>,
|
pub migration: Option<MigrationConfig>,
|
||||||
pub ollama: OllamaConfig,
|
pub ollama: OllamaConfig,
|
||||||
pub display: DisplayConfig,
|
pub display: DisplayConfig,
|
||||||
|
pub tier: Tier,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RobinConfig {
|
impl Default for RobinConfig {
|
||||||
|
|
@ -63,6 +80,7 @@ impl Default for RobinConfig {
|
||||||
migration: None,
|
migration: None,
|
||||||
ollama: OllamaConfig::default(),
|
ollama: OllamaConfig::default(),
|
||||||
display: DisplayConfig::default(),
|
display: DisplayConfig::default(),
|
||||||
|
tier: Tier::Free,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,4 +154,36 @@ mod tests {
|
||||||
let deserialized: RobinConfig = toml::from_str(&serialized).unwrap();
|
let deserialized: RobinConfig = toml::from_str(&serialized).unwrap();
|
||||||
assert!(!deserialized.needs_onboarding());
|
assert!(!deserialized.needs_onboarding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn notification_level_default_is_badge_and_toast() {
|
||||||
|
let config = RobinConfig::default();
|
||||||
|
assert!(matches!(
|
||||||
|
config.display.notification_level,
|
||||||
|
NotificationLevel::BadgeAndToast
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tier_default_is_free() {
|
||||||
|
let config = RobinConfig::default();
|
||||||
|
assert!(matches!(config.tier, Tier::Free));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn notification_level_roundtrips_toml() {
|
||||||
|
let config = RobinConfig {
|
||||||
|
display: DisplayConfig {
|
||||||
|
notification_level: NotificationLevel::BadgeOnly,
|
||||||
|
quiet_mode: false,
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let toml = toml::to_string_pretty(&config).unwrap();
|
||||||
|
let back: RobinConfig = toml::from_str(&toml).unwrap();
|
||||||
|
assert!(matches!(
|
||||||
|
back.display.notification_level,
|
||||||
|
NotificationLevel::BadgeOnly
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue