-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtest-go.sh
More file actions
executable file
·54 lines (45 loc) · 1.31 KB
/
test-go.sh
File metadata and controls
executable file
·54 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# This script tests the SDK modules
# To skip manually maintained files, pass an extra "true" argument
# Pre-requisites: Go
set -eo pipefail
# Arguments
SKIP_NON_GENERATED_FILES="${1}"
SERVICE="${2}"
# Default values
if [ ! "${SKIP_NON_GENERATED_FILES}" = true ]; then
SKIP_NON_GENERATED_FILES=false
fi
ROOT_DIR=$(git rev-parse --show-toplevel)
GOTEST_ARGS="-timeout=5m -cover -count=1"
CORE_PATH="${ROOT_DIR}/core"
SERVICES_PATH="${ROOT_DIR}/services"
if type -p go >/dev/null; then
:
else
echo "Go not installed, unable to proceed."
exit 1
fi
test_service() {
service=$1
echo ">> Testing services/${service}"
if [ "${SKIP_NON_GENERATED_FILES}" = true ]; then
go test ${SERVICES_PATH}/${service} ${GOTEST_ARGS} # All manually maintained files are in subfolders
else
go test ${SERVICES_PATH}/${service}/... ${GOTEST_ARGS}
fi
}
# If a service is specified, only test that service
if [ ! -z "${SERVICE}" ]; then
test_service ${SERVICE}
# Otherwise, test all services and core
else
if [ "${SKIP_NON_GENERATED_FILES}" = false ]; then
echo ">> Testing core"
go test ${CORE_PATH}/... ${GOTEST_ARGS}
fi
for service_dir in ${SERVICES_PATH}/*; do
service=$(basename ${service_dir})
test_service ${service}
done
fi