#!/bin/sh

set -ex

# required for the debian adt host
if [ "$http_proxy" != "" ]; then
    sudo mkdir -p /etc/systemd/system/snapd.service.d/
    sudo cat <<EOF | sudo tee -a /etc/systemd/system/snapd.service.d/proxy.conf
[Service]
Environment=http_proxy=$http_proxy
Environment=https_proxy=$http_proxy
EOF
    sudo systemctl daemon-reload
fi

# ensure our PATH is right
. /etc/profile.d/apps-bin-path.sh

tmp="$(mktemp -d)"
export GOPATH=$tmp
./get-deps.sh
mkdir -p $GOPATH/src/github.com/ubuntu-core/
cp -R . $GOPATH/src/github.com/ubuntu-core/snappy/
mkdir $GOPATH/src/github.com/ubuntu-core/snappy/integration-tests/data/output
cp debian/tests/testconfig.json $GOPATH/src/github.com/ubuntu-core/snappy/integration-tests/data/output/
cd $GOPATH/src/github.com/ubuntu-core/snappy
go test -c ./integration-tests/tests

./tests.test  -check.vv -check.f 'snapHelloWorldExampleSuite|searchSuite|installAppSuite'
