use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "kebab-case")]
pub struct DesktopConfig {
#[serde(default = "default_suggest_install")]
pub suggest_install: bool,
}
impl Default for DesktopConfig {
fn default() -> Self {
Self { suggest_install: default_suggest_install() }
}
}
fn default_suggest_install() -> bool {
true
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn suggest_install_defaults_on() {
assert!(DesktopConfig::default().suggest_install);
let parsed: DesktopConfig = toml::from_str("").expect("empty table parses");
assert!(parsed.suggest_install);
}
#[test]
fn suggest_install_opt_out_parses() {
let parsed: DesktopConfig = toml::from_str("suggest-install = false").expect("opt-out parses");
assert!(!parsed.suggest_install);
}
}