From bff78ccc21ede551ba5409aaa55cebce1cdef9d7 Mon Sep 17 00:00:00 2001 From: Bauke Date: Fri, 28 Oct 2022 14:06:03 +0200 Subject: [PATCH] Add a with-hooks test. --- tests/parsing.rs | 1 + tests/parsing/with-hooks.toml | 12 ++++++++ tests/snapshots/parsing__with-hooks.snap | 35 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/parsing/with-hooks.toml create mode 100644 tests/snapshots/parsing__with-hooks.snap diff --git a/tests/parsing.rs b/tests/parsing.rs index 0485736..3a290ba 100644 --- a/tests/parsing.rs +++ b/tests/parsing.rs @@ -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)?; diff --git a/tests/parsing/with-hooks.toml b/tests/parsing/with-hooks.toml new file mode 100644 index 0000000..166bcfc --- /dev/null +++ b/tests/parsing/with-hooks.toml @@ -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" diff --git a/tests/snapshots/parsing__with-hooks.snap b/tests/snapshots/parsing__with-hooks.snap new file mode 100644 index 0000000..fa473a2 --- /dev/null +++ b/tests/snapshots/parsing__with-hooks.snap @@ -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", + ), + }, + }, + ], +}