forked from warrensbox/tgswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-tgswitch.sh
executable file
·93 lines (84 loc) · 2.36 KB
/
test-tgswitch.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
if [[ ! -f "./build/tgswitch" ]]; then
echo "Cannot run test.."
echo "Build does not exist"
exit 1
fi
#find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH;do ./build/tgswitch -c "${TEST_PATH}" || exit 1; done;
function commentStart(){
echo "### Test start ###"
}
function commentComplete(){
echo "### Test complete ###"
echo ""
}
function runtestdir(){
commentStart
test_case=$1
dir=$2
expected_version=$3
echo "Test $test_case file"
./build/tgswitch -c ./test-data/"$dir" || exit 1
version=$(terragrunt -v | awk '{print $3}')
echo "$version"
sleep 1
if [[ "$version" == "$expected_version" ]]; then
echo "Switch successful"
else
echo "Switch failed"
exit 1
fi
commentComplete
}
function runtestenv(){
commentStart
test_case=$1
env=$2
expected_version=$3
echo "Test $test_case"
export TG_VERSION="$env"
./build/tgswitch || exit 1
version=$(terragrunt -v | awk '{print $3}')
echo "$version"
sleep 1
if [[ "$version" == "$expected_version" ]]; then
echo "Switch successful"
else
echo "Switch failed"
exit 1
fi
commentComplete
}
function runtestarg(){
commentStart
test_case=$1
arg=$2
expected_version=$3
echo "Test $test_case"
./build/tgswitch "$arg"|| exit 1
version=$(terragrunt -v | awk '{print $3}')
echo "$version"
sleep 1
if [[ "$version" == "$expected_version" ]]; then
echo "Switch successful"
else
echo "Switch failed"
exit 1
fi
commentComplete
}
runtestdir "terragrunt version" "test_terragrunt-version" "v0.36.0"
runtestdir "terragrunt hcl" "test_terragrunt_hcl" "v0.36.0"
runtestdir "tgswitchrc" "test_tgswitchrc" "v0.33.0"
runtestdir ".toml" "test_tgswitchtoml" "v0.34.0"
runtestenv "env variable" "0.37.1" "v0.37.1"
runtestarg "passing argument" "0.36.1" "v0.36.1"
# M1 darwin arm64 test versions < 0.28.12
runtestdir "terragrunt version" "test_terragrunt-version_m1" "v0.26.7"
runtestdir "terragrunt hcl" "test_terragrunt_hcl_m1" "v0.28.0"
runtestdir "tgswitchrc" "test_tgswitchrc_m1" "v0.28.0"
runtestdir ".toml" "test_tgswitchtoml_m1" "v0.26.7"
runtestenv "env variable" "0.26.7" "v0.26.7"
runtestarg "passing argument" "0.26.7" "v0.26.7"
# Edge case
runtestarg "passing argument" "0.28.12" "v0.28.12"