tests: Move assert_fail function to tests/libtest.sh

This moves the assert_fail function definition which was defined
and called in tests/test-remote-headers.sh. Done in preparation
for use of the assert_fail function in other test files.

Closes: #1669
Approved by: jlebon
This commit is contained in:
Robert Fairley 2018-07-05 12:30:05 -04:00 committed by Atomic Bot
parent 3696e1cfdd
commit 4f096c8f11
2 changed files with 9 additions and 9 deletions

View File

@ -648,3 +648,12 @@ assert_not_ref () {
fatal "rev-parse $2 unexpectedly succeeded!" fatal "rev-parse $2 unexpectedly succeeded!"
fi fi
} }
assert_fail () {
set +e
$@
if [ $? = 0 ] ; then
echo 1>&2 "$@ did not fail"; exit 1
fi
set -euo pipefail
}

View File

@ -33,15 +33,6 @@ setup_fake_remote_repo1 "archive" "" \
--expected-header baz=badger \ --expected-header baz=badger \
--expected-header "User-Agent=libostree/$V dodo/2.15" --expected-header "User-Agent=libostree/$V dodo/2.15"
assert_fail (){
set +e
$@
if [ $? = 0 ] ; then
echo 1>&2 "$@ did not fail"; exit 1
fi
set -euo pipefail
}
cd ${test_tmpdir} cd ${test_tmpdir}
rm repo -rf rm repo -rf
mkdir repo mkdir repo