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

Fix build and enable tests #75

Merged
merged 6 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitpod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tasks:
- command: "npm install && npm test"
ports:
- port: 8080
protocol: "http"
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ language: node_js
node_js:
- "6"
- "8"
- "node"
install: npm install
script: npm test
script: ./.travis_script.sh
39 changes: 39 additions & 0 deletions .travis_script.sh
Original file line number Diff line number Diff line change
@@ -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://localhost: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
Loading