From d8e758387ca3e61d9d22bd3873568f282ed7a187 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Wed, 4 Mar 2026 07:22:46 +0100 Subject: [PATCH] Add partial change example ```git-check-assertions sed -i 's/HEAD~/HEAD/' test/git-check-assertions.bats run test/git-check-assertions.bats assert_failure assert_output --partial "Expected command to fail, but it succeeded." ``` --- README.md | 11 +++++++++++ test/git-check-assertions.bats | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 3eb57c4..f1cfb95 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,14 @@ run dotnet test --no-build assert_failure ``` ~~~ + +Assert that a specific change in a commit is necessary for the tests to succeed: + +~~~ +```git-check-assertions +git checkout HEAD~ Main.fs +run dotnet test +assert_failure +assert_output --partial "Invalid URL" +``` +~~~ diff --git a/test/git-check-assertions.bats b/test/git-check-assertions.bats index 697d47d..2e45490 100755 --- a/test/git-check-assertions.bats +++ b/test/git-check-assertions.bats @@ -113,6 +113,22 @@ commit_with_assertion() { assert_success } +@test "you can use git checkout in an assertion to assert against a mixed version of the code" { + git checkout -b feature + echo hello >src + echo 'grep hello src' >tests + git add src tests + git commit -m 'add src and tests' + echo goodbye >src + echo 'grep goodbye src' >tests + git add src tests + commit_with_assertion $'git checkout HEAD~ src\nrun bash tests\nassert_failure' + + run git-check-assertions + + assert_success +} + @test "assert_success should succeed if the executed command succeeded" { git checkout -b feature commit_with_assertion $'run exit 0\nassert_success'