Created
April 23, 2020 11:28
-
-
Save teghnet/9eeafe09ad5871e3ee805972476f5c39 to your computer and use it in GitHub Desktop.
Code described at https://www.tegh.net/knowledge/testing-in-a-pipeline/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM bash | |
COPY test*.sh ./ | |
RUN bash test_scenario.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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