Skip to content

Commit

Permalink
Split languages tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Nov 21, 2024
1 parent da3df1d commit c3d1c35
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 33 deletions.
34 changes: 34 additions & 0 deletions tests/languages/docker.rs
Original file line number Diff line number Diff line change
@@ -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 -----
"#);
}
34 changes: 1 addition & 33 deletions tests/language.rs → tests/languages/fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 -----
"#);
}
6 changes: 6 additions & 0 deletions tests/languages/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[path = "../common/mod.rs"]
mod common;

#[cfg(all(feature = "docker", target_os = "linux"))]
mod docker;
mod fail;

0 comments on commit c3d1c35

Please sign in to comment.