#!/bin/bash

set -e

# replace admin password and secret in test config
pushd test-config/environments/"${ENVIRONMENT_NAME}"
SMOKE_PASSWORD=$(grep cf_networking_smoke_user_password vars-store.yml  | cut -d' ' -f2)
  sed -i -- "s/{{smoke-password}}/${SMOKE_PASSWORD}/g" smoke-config.json
popd

ENVIRONMENT_PATH="test-config/environments/${ENVIRONMENT_NAME}/smoke-config.json"
export CONFIG=${PWD}/${CONFIG:-"${ENVIRONMENT_PATH}"}

echo "$CONFIG"

cd cf-networking
export GOPATH=$PWD

go build -o /tmp/bin/network-policy-plugin ./src/cli-plugin
cf install-plugin -f /tmp/bin/network-policy-plugin

cd src/test/smoke
export APPS_DIR=../../example-apps
ginkgo -r -v
