Break up test scripts
This commit is contained in:
38
test/test_head.sh
Executable file
38
test/test_head.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
function TestGetHeader()
|
||||
{
|
||||
curlHeaderOutputFile="./temp"
|
||||
if curl -I $1 --output $curlHeaderOutputFile 2> /dev/null; then
|
||||
regexPattern="Content\-Type: $2"
|
||||
headerContentType="$(egrep -o "$regexPattern" $curlHeaderOutputFile)"
|
||||
if [ -n "$headerContentType" ]; then
|
||||
echo "SUCCESS GET headers for $1 has correct MIME type"
|
||||
else
|
||||
echo "FAILURE GET headers for $1 contains bad MIME type (expected <Content-Type: $2> but got <$headerContentType>)"
|
||||
fi
|
||||
|
||||
rm $curlHeaderOutputFile
|
||||
else
|
||||
echo "FAILURE Cannot GET headers for $1"
|
||||
fi
|
||||
}
|
||||
|
||||
function TestHEAD()
|
||||
{
|
||||
getUrl="http://localhost:8080/$1"
|
||||
|
||||
TestGetHeader $getUrl $2
|
||||
echo ""
|
||||
}
|
||||
|
||||
echo "*********"
|
||||
echo "HEAD TEST"
|
||||
echo "*********"
|
||||
TestHEAD "index.html" 'text/html'
|
||||
TestHEAD "robedude.png" 'image/png'
|
||||
TestHEAD "hope.jpg" 'image/jpeg'
|
||||
TestHEAD "nevada.mp3" 'audio/mpeg3'
|
||||
TestHEAD "index.css" 'text/css'
|
||||
TestHEAD "test.js" 'application/javascript'
|
||||
TestHEAD "subdir/index.html" 'text/html'
|
||||
Reference in New Issue
Block a user