Add a test for serializing and update snapshots.
This commit is contained in:
parent
7a543409ba
commit
3f0f643a8a
|
@ -0,0 +1,34 @@
|
|||
use {
|
||||
hooked::{Config, ExitAction, 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()),
|
||||
on_failure: ExitAction::Continue,
|
||||
task: Task {
|
||||
command: Some("exit 0".to_string()),
|
||||
script: None,
|
||||
},
|
||||
};
|
||||
|
||||
let pre_commit_script = PreCommit {
|
||||
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());
|
||||
}
|
|
@ -6,4 +6,5 @@ Config {
|
|||
general: General {
|
||||
directory: "hooks",
|
||||
},
|
||||
pre_commit: [],
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
source: tests/serialize.rs
|
||||
expression: to_string_pretty(&config).unwrap()
|
||||
---
|
||||
[general]
|
||||
directory = 'hooks'
|
||||
|
||||
[[pre_commit]]
|
||||
name = 'Command Test'
|
||||
on_failure = 'continue'
|
||||
command = 'exit 0'
|
||||
|
||||
[[pre_commit]]
|
||||
name = 'Script Test'
|
||||
on_failure = 'stop'
|
||||
script = 'test.sh'
|
||||
|
Loading…
Reference in New Issue