#!/bin/bash
# script should fail when any process returns non zero code
set -e

cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
python -m coverage run manage.py test --settings=core.settings_test $1

coverage_python=`coverage report -m | tail -n1 | awk '{print $4}'`
commit=`git rev-parse HEAD`
data="{\"${commit}/coverage_python\": \"${coverage_python}\"}"
curl -X PATCH -d "${data}" 'https://commit-metadata.firebaseio.com/commits.json'
