diff --git a/scripts/test_e2e.sh b/scripts/test_e2e.sh index 5b20a041..8d6fc52b 100755 --- a/scripts/test_e2e.sh +++ b/scripts/test_e2e.sh @@ -6,26 +6,40 @@ set -xeuo pipefail REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/.." + +OGOPATH=${GOPATH:-} +OGO111MODULE=${GO111MODULE:-} +OGOPROXY=${GOPROXY:-} export GO_BINARY_PATH=${GO_BINARY_PATH:-go} TMPDIR=$(mktemp -d) +export GOPATH=$TMPDIR GOMOD_CACHE=$TMPDIR/pkg/mod export PATH=${REPO_DIR}/bin:${PATH} clearGoModCache () { + chmod -R 0770 ${GOMOD_CACHE} rm -fr ${GOMOD_CACHE} } teardown () { # Cleanup after our tests - pkill proxy || true + [[ -z "${OGOPATH}" ]] && unset GOPATH || export GOPATH=$OGOPATH + [[ -z "${OGO111MODULE}" ]] && unset GO111MODULE || export GO111MODULE=$OGO111MODULE + [[ -z "${OGOPROXY}" ]] && unset GOPROXY || export GOPROXY=$OGOPROXY + + clearGoModCache + pkill athens-proxy || true + rm -fr ${TMPDIR} popd 2> /dev/null || true } trap teardown EXIT +export GO111MODULE=on + # Start the proxy in the background and wait for it to be ready cd $REPO_DIR/cmd/proxy -pkill proxy || true # cleanup proxy if it is running -go build -mod=vendor && ./proxy & +pkill athens-proxy || true # cleanup proxy if it is running +go build -mod=vendor -o athens-proxy && ./athens-proxy & while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000)" != "200" ]]; do sleep 5; done # Clone our test repo @@ -34,15 +48,11 @@ 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 . +# clear cache so that go uses the proxy clearGoModCache # Verify that the test works against the proxy