test: de minimis test for style deser

buddies-main-deployment
James Prestwich 3 years ago
parent 4de7e35cc7
commit 534ee25b90
No known key found for this signature in database
GPG Key ID: 7CC174C250AD83AD
  1. 46
      rust/optics-base/src/settings/trace/fmt.rs

@ -11,7 +11,7 @@ use tracing_subscriber::{
};
/// Basic tracing configuration
#[derive(Debug, Clone, Copy, serde::Deserialize)]
#[derive(Debug, Clone, Copy, serde::Deserialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum Style {
/// Pretty print
@ -203,3 +203,47 @@ where
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[derive(serde::Deserialize)]
struct TestStyle {
style: Style,
}
#[test]
fn it_deserializes_formatting_strings() {
let case = r#"{"style": "pretty"}"#;
assert_eq!(
serde_json::from_str::<TestStyle>(case).unwrap().style,
Style::Pretty
);
let case = r#"{"style": "compact"}"#;
assert_eq!(
serde_json::from_str::<TestStyle>(case).unwrap().style,
Style::Compact
);
let case = r#"{"style": "full"}"#;
assert_eq!(
serde_json::from_str::<TestStyle>(case).unwrap().style,
Style::Full
);
let case = r#"{"style": "json"}"#;
assert_eq!(
serde_json::from_str::<TestStyle>(case).unwrap().style,
Style::Json
);
let case = r#"{"style": "toast"}"#;
assert_eq!(
serde_json::from_str::<TestStyle>(case).unwrap().style,
Style::Full
);
}
}

Loading…
Cancel
Save