forked from Ravenstine/awsdown
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtestFuncs.sh
executable file
·48 lines (42 loc) · 1.56 KB
/
testFuncs.sh
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
#!/bin/bash
DOCKER_PATH=$(which docker)
if [ "$DOCKER_PATH" == "" ]; then
echo "Cannot find docker" >&2
exit 1
fi
LOCALSTACK_EDGE_PORT=4566
IFS=''
function readDockerContainerState() {
local data
local name=$1
local prefix=$(printf '%s\n' "$name" | awk '{ print toupper($0) }')
read -ra data <<<$(docker container ls -a --filter name=$name --format='"{{.ID}}" "{{.Names}}" "{{.Status}}""' | awk '{print $1" "$2" "$3 "\""}')
command eval "local data=($data)"
if [ "$data" != "" ]; then
command eval "${prefix}_ID=\"${data[0]}\""
command eval "${prefix}_NAME=\"${data[1]}\""
local status=$(printf '%s\n' "${data[2]}" | awk '{ print tolower($0) }')
command eval "${prefix}_STATUS=\"${status}\""
fi
}
function findContainerState() {
local data
local name=$2
local ancestor=$1
local prefix=$(printf '%s\n' "$name" | awk '{ print toupper($0) }')
read -ra data <<<$(docker ps --filter "ancestor=$ancestor" --format='"{{.ID}}" "{{.Names}}" "{{.Status}}""' | awk '{print $1" "$2" "$3 "\""}')
command eval "local data=($data)"
if [ "$data" != "" ]; then
command eval "${prefix}_ID=\"${data[0]}\""
command eval "${prefix}_NAME=\"${data[1]}\""
local status=$(printf '%s\n' "${data[2]}" | awk '{ print tolower($0) }')
command eval "${prefix}_STATUS=\"${status}\""
fi
}
function runTests() {
if [ "$CI" != "true" ]; then
nyc ts-node node_modules/tape/bin/tape ./test/** | faucet || true
else
nyc ts-node node_modules/tape/bin/tape ./test/** | tap-junit -s 'DynamoDBDown All Tests' -o build/junit -n results.xml || true
fi
}