Introduce --partial on assert_output
This commit is contained in:
parent
475b0c6fa1
commit
3036d6d37e
2 changed files with 29 additions and 0 deletions
|
|
@ -53,6 +53,15 @@ assert_failure() {
|
|||
fi
|
||||
}
|
||||
assert_output() {
|
||||
if [ "${1:-}" = "--partial" ]; then
|
||||
local expected="$2"
|
||||
if [[ "$output" != *"$expected"* ]]; then
|
||||
echo "Expected output to contain: $expected"
|
||||
echo "Actual output: $output"
|
||||
exit 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
if [ "$output" != "$1" ]; then
|
||||
echo "Expected output to equal: $1"
|
||||
echo "Actual output: $output"
|
||||
|
|
|
|||
|
|
@ -179,3 +179,23 @@ commit_with_assertion() {
|
|||
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "assert_output --partial should succeed if output contains the given string" {
|
||||
git checkout -b feature
|
||||
commit_with_assertion $'run echo hello\nassert_output --partial ell'
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "assert_output --partial should fail if output does not contain the given string" {
|
||||
git checkout -b feature
|
||||
commit_with_assertion $'run echo hello\nassert_output --partial xyz'
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_failure
|
||||
assert_output --partial "Expected output to contain: xyz"
|
||||
assert_output --partial "Actual output: hello"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue