diff --git a/tests/languages/docker.rs b/tests/languages/docker.rs new file mode 100644 index 0000000..ed2463d --- /dev/null +++ b/tests/languages/docker.rs @@ -0,0 +1,34 @@ +use anyhow::Result; +use assert_fs::prelude::*; + +use crate::common::{cmd_snapshot, TestContext}; + +/// GitHub Action only has docker for linux hosted runners. +#[test] +fn docker() { + let context = TestContext::new(); + context.init_project(); + + context.write_pre_commit_config(indoc::indoc! {r#" + repos: + - repo: https://github.com/j178/pre-commit-docker-hooks + rev: master + hooks: + - id: hello-world + entry: "echo Hello, world!" + always_run: true + "#}); + + context.git_add("."); + + cmd_snapshot!(context.filters(), context.run(), @r#" + success: true + exit_code: 0 + ----- stdout ----- + Cloning https://github.com/j178/pre-commit-docker-hooks@master + Installing environment for https://github.com/j178/pre-commit-docker-hooks@master + Hello World..............................................................Passed + + ----- stderr ----- + "#); +} diff --git a/tests/language.rs b/tests/languages/fail.rs similarity index 57% rename from tests/language.rs rename to tests/languages/fail.rs index 2b163d5..15347de 100644 --- a/tests/language.rs +++ b/tests/languages/fail.rs @@ -3,8 +3,7 @@ use assert_fs::prelude::*; use crate::common::{cmd_snapshot, TestContext}; -mod common; - +/// GitHub Action only has docker for linux hosted runners. #[test] fn fail() -> Result<()> { let context = TestContext::new(); @@ -44,34 +43,3 @@ fn fail() -> Result<()> { Ok(()) } - -/// GitHub Action only has docker for linux hosted runners. -#[test] -#[cfg(all(feature = "docker", target_os = "linux"))] -fn docker() { - let context = TestContext::new(); - context.init_project(); - - context.write_pre_commit_config(indoc::indoc! {r#" - repos: - - repo: https://github.com/j178/pre-commit-docker-hooks - rev: master - hooks: - - id: hello-world - entry: "echo Hello, world!" - always_run: true - "#}); - - context.git_add("."); - - cmd_snapshot!(context.filters(), context.run(), @r#" - success: true - exit_code: 0 - ----- stdout ----- - Cloning https://github.com/j178/pre-commit-docker-hooks@master - Installing environment for https://github.com/j178/pre-commit-docker-hooks@master - Hello World..............................................................Passed - - ----- stderr ----- - "#); -} diff --git a/tests/languages/main.rs b/tests/languages/main.rs new file mode 100644 index 0000000..2d01d7a --- /dev/null +++ b/tests/languages/main.rs @@ -0,0 +1,6 @@ +#[path = "../common/mod.rs"] +mod common; + +#[cfg(all(feature = "docker", target_os = "linux"))] +mod docker; +mod fail;