Skip to content

Instantly share code, notes, and snippets.

@teghnet
Created April 23, 2020 11:28
Show Gist options
  • Save teghnet/9eeafe09ad5871e3ee805972476f5c39 to your computer and use it in GitHub Desktop.
Save teghnet/9eeafe09ad5871e3ee805972476f5c39 to your computer and use it in GitHub Desktop.
FROM bash
COPY test*.sh ./
RUN bash test_scenario.sh
set -e
function _clean() {
rm -f file-?.txt
}
function _testsShouldPass() {
echo -n "Test #$1: "
if bash tests.sh; then
echo "PASS"
else
echo "FAIL"
_clean
return 1
fi
}
function _testsShouldFail() {
echo -n "Test #$1: "
if ! bash tests.sh; then
echo "PASS"
else
echo "FAIL"
_clean
return 1
fi
}
_clean
_testsShouldFail 1
touch file-a.txt
_testsShouldFail 2
touch file-b.txt
_testsShouldFail 3
touch file-c.txt
_testsShouldPass 4
rm file-a.txt
_testsShouldFail 5
touch file-a.txt
rm file-b.txt
_testsShouldFail 6
touch file-b.txt
rm file-c.txt
_testsShouldFail 7
_clean
set -e
test -f file-a.txt
test -f file-b.txt
test -f file-c.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment