Add a with-hooks test.

This commit is contained in:
Bauke 2022-10-28 14:06:03 +02:00
parent c47d0a1e6e
commit bff78ccc21
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
3 changed files with 48 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use {color_eyre::Result, hooked::Config};
use {insta::assert_debug_snapshot, test_case::test_case};
#[test_case("defaults" ; "defaults")]
#[test_case("with-hooks" ; "with-hooks")]
fn test_config_parsing(file_name: &str) -> Result<()> {
let file = PathBuf::from(format!("tests/parsing/{file_name}.toml"));
let config = Config::from_toml_file(file)?;

View File

@ -0,0 +1,12 @@
[general]
directory = "hooked"
[[pre_commit]]
name = "Pre Commit 1"
command = "exit 0"
on_failure = "continue"
[[pre_commit]]
name = "Pre Commit 2"
script = "test.sh"
on_failure = "stop"

View File

@ -0,0 +1,35 @@
---
source: tests/parsing.rs
expression: config
---
Config {
general: General {
directory: "hooked",
},
pre_commit: [
PreCommit {
name: Some(
"Pre Commit 1",
),
on_failure: Continue,
task: Task {
command: Some(
"exit 0",
),
script: None,
},
},
PreCommit {
name: Some(
"Pre Commit 2",
),
on_failure: Stop,
task: Task {
command: None,
script: Some(
"test.sh",
),
},
},
],
}