hooked/hooked-config/tests/serialize.rs

39 lines
899 B
Rust
Raw Normal View History

use {
hooked_config::{Config, ExitAction, NoiseLevel, PreCommit, Task},
toml::to_string_pretty,
};
use insta::assert_snapshot;
#[test]
fn test_serialize() {
let pre_commit_command = PreCommit {
name: Some("Command Test".to_string()),
2024-01-18 11:27:27 +00:00
noise_level: None,
on_failure: ExitAction::Continue,
2022-11-27 16:29:44 +00:00
staged: vec!["*.txt".to_string()],
task: Task {
command: Some("exit 0".to_string()),
script: None,
},
};
let pre_commit_script = PreCommit {
name: Some("Script Test".to_string()),
2024-01-18 11:27:27 +00:00
noise_level: Some(NoiseLevel::Loud),
on_failure: ExitAction::Stop,
2022-11-27 16:29:44 +00:00
staged: vec![],
task: Task {
command: None,
script: Some("test.sh".into()),
},
};
let config = Config {
general: Default::default(),
pre_commit: vec![pre_commit_command, pre_commit_script],
};
assert_snapshot!("serialize", to_string_pretty(&config).unwrap());
}