Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Run simple end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinkihaveacat committed Oct 4, 2018
1 parent 9cf9596 commit 9c79b63
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,4 +4,4 @@ node_js:
- "8"
- "node"
install: npm install
script: npm test
script: ./.travis_script.sh
39 changes: 39 additions & 0 deletions .travis_script.sh
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

npm test || exit

trap 'kill $(jobs -p)' EXIT

fetch() {
echo "TESTING $1"
res=$(curl -ksSo /dev/null -w "status:%{http_code} time:%{time_total} (%{size_download} bytes)" $1)
if [[ $? -ne 0 ]]; then
echo "ERROR $res"
return
fi
if echo $res | grep -q "status:200" ; then
echo "PASS $res"
else
echo "FAIL $res"
fi
}

echo "STARTING AMPBENCH"

npm start > npm_start.log 2>&1 &

sleep 5 # wait for server to start

echo
echo "RUNNING TESTS"
echo

fetch 'http://jjlocalhost:8080/validate?url=http://www.bbc.com/news/amp/36884290'
fetch 'http://localhost:8080/validate?url=https://www.bbc.com/news/amp/36884290'
fetch 'http://localhost:8080/api2?url=https://www.bbc.com/news/amp/36884290'

kill $(jobs -p)

echo
echo "NPM LOG"
cat npm_start.log

0 comments on commit 9c79b63

Please sign in to comment.