2022-10-28 12:03:01 +00:00
|
|
|
use {
|
2022-10-31 14:35:10 +00:00
|
|
|
hooked_config::{Config, ExitAction, PreCommit, Task},
|
2022-10-28 12:03:01 +00:00
|
|
|
toml::to_string_pretty,
|
|
|
|
};
|
|
|
|
|
|
|
|
use insta::assert_snapshot;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_serialize() {
|
|
|
|
let pre_commit_command = PreCommit {
|
2022-11-20 11:20:59 +00:00
|
|
|
git_staged: vec!["*.txt".to_string()],
|
2022-10-28 12:03:01 +00:00
|
|
|
name: Some("Command Test".to_string()),
|
|
|
|
on_failure: ExitAction::Continue,
|
|
|
|
task: Task {
|
|
|
|
command: Some("exit 0".to_string()),
|
|
|
|
script: None,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let pre_commit_script = PreCommit {
|
2022-11-20 11:20:59 +00:00
|
|
|
git_staged: vec![],
|
2022-10-28 12:03:01 +00:00
|
|
|
name: Some("Script Test".to_string()),
|
|
|
|
on_failure: ExitAction::Stop,
|
|
|
|
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());
|
|
|
|
}
|