Files
athens/scripts/test_e2e.sh
Rob j Loranger 43d7501420 Update e2e tests to not use sudo (#477)
* Update e2e tests to not use sudo

Using a system temporary directory via mktemp we can place our GOMOD_CACHE
in a place that does not require root permission to clear.

As well we use the environment variable for GO_BINARY_PATH to point to
a module compatible go version. At this time, 1.11beta3.

* add GO_BINARY_PATH to travis

* Use conditional GO_BINARY_PATH

Co-authored-by: robbie <hello@robloranger.ca>
Co-authored-by: carolyn <me@carolynvanslyck.com>

* no longer needs to set GO_BINARY_PATH in env
2018-08-15 19:16:14 +02:00

51 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# test_e2e.sh
# Execute end-to-end (e2e) tests to verify that everything is working right
# from the end user perpsective
set -xeuo pipefail
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/.."
export GO_BINARY_PATH=${GO_BINARY_PATH:-go}
TMPDIR=$(mktemp -d)
GOMOD_CACHE=$TMPDIR/pkg/mod
export PATH=${REPO_DIR}/bin:${PATH}
clearGoModCache () {
rm -fr ${GOMOD_CACHE}
}
teardown () {
# Cleanup after our tests
pkill buffalo || true
popd 2> /dev/null || true
}
trap teardown EXIT
# Start the proxy in the background and wait for it to be ready
cd $REPO_DIR/cmd/proxy
pkill buffalo || true # cleanup old buffalos
buffalo dev &
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000)" != "200" ]]; do sleep 5; done
# Clone our test repo
TEST_SOURCE=${TMPDIR}/happy-path
rm -fr ${TEST_SOURCE} 2> /dev/null || true
git clone https://github.com/athens-artifacts/happy-path.git ${TEST_SOURCE}
pushd ${TEST_SOURCE}
clearGoModCache
# set modules on after running buffalo dev, not sure why
# issue https://github.com/gomods/athens/issues/412
export GO111MODULE=on
# Make sure that our test repo works without the GOPROXY first
unset GOPROXY
$GO_BINARY_PATH run .
clearGoModCache
# Verify that the test works against the proxy
export GOPROXY=http://localhost:3000
$GO_BINARY_PATH run .