Add a with-hooks test.
This commit is contained in:
parent
c47d0a1e6e
commit
bff78ccc21
|
@ -5,6 +5,7 @@ use {color_eyre::Result, hooked::Config};
|
||||||
use {insta::assert_debug_snapshot, test_case::test_case};
|
use {insta::assert_debug_snapshot, test_case::test_case};
|
||||||
|
|
||||||
#[test_case("defaults" ; "defaults")]
|
#[test_case("defaults" ; "defaults")]
|
||||||
|
#[test_case("with-hooks" ; "with-hooks")]
|
||||||
fn test_config_parsing(file_name: &str) -> Result<()> {
|
fn test_config_parsing(file_name: &str) -> Result<()> {
|
||||||
let file = PathBuf::from(format!("tests/parsing/{file_name}.toml"));
|
let file = PathBuf::from(format!("tests/parsing/{file_name}.toml"));
|
||||||
let config = Config::from_toml_file(file)?;
|
let config = Config::from_toml_file(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"
|
|
@ -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",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
Loading…
Reference in New Issue