#!/bin/bash

if [[ ! -x "$(command -v go)" ]]; then
  echo >&2 "go runtime is required: https://golang.org/doc/install"
  echo >&2 "You can use scripts/go-wrapper $0 to use go in a docker container."
  exit 1
fi

SOURCE_DIRECTORY=$(dirname "${BASH_SOURCE[0]}")
cd "${SOURCE_DIRECTORY}/.."

if [ -z "$REDIS_DISABLE_BOOTSTRAP" ]; then
    export REDIS_URI="redis://localhost:26379/1"
    scripts/redis --restart
fi

go test -count=1 -race -v $(go list ./... | grep -v -E '\/(vendor|examples)\/')
