Last active
February 7, 2018 04:20
-
-
Save zbentley/b7fae567de6a2542c709ca103c000802 to your computer and use it in GitHub Desktop.
Panzerbjörne
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
function testshit { | |
local testname="${1:?Test name needs to be first parameter bro}" | |
local url="${2:?URL needs to be second parameter bro}" | |
local regex="${3:?Regex needs to be third parameter bro}" | |
# Can do this multiple times if you want with different CURL args to e.g. test the headers/response code/body: | |
local curlout=$(curl -whatever "$url") | |
if echo "$curlout" | grep -P "$regex" >/dev/null; then | |
echo "$testname ($url): all good" | |
else | |
echo -e "$testname ($url): failed\nexpected to match: $regex\nInstead, got output:$curlout" | |
fi | |
} | |
testshit "my first test" "http://getfuct.org.biz" "^it's fucked br[oO]$" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment