#!/bin/bash
# Note: should run as root@ in UBUNTU

# Setup test environment
apt-get install -y nodejs npm curl
ln -sf /usr/bin/nodejs /usr/bin/node 
npm install 

# Run tests 
node tests/test_server.js &
sleep 3
curl --output "/tmp/test.json" "http://127.0.0.1:8888/"
sleep 1
pkill -9 "node"
diff tests/test_golden.json /tmp/test.json >/tmp/diff
if [ -s /tmp/diff ]
then
	echo
	echo
	cat /tmp/diff
	echo "  Tests Fail!"
	exit 1
fi

echo 
echo
echo "  Tests Pass!"

