-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path31-conf.bats
More file actions
103 lines (86 loc) · 2.25 KB
/
31-conf.bats
File metadata and controls
103 lines (86 loc) · 2.25 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
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
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bats
#
# 30 - initialization and configuration
#
load app
reset/vars(){
for var in "${APP_VARS[@]}"; do
eval "unset \$var"
done
}
default/val(){
case "$1" in
DEX_BIN_DIR) echo "$DEX_HOME/bin" ;;
DEX_BIN_PREFIX) echo "d" ;;
DEX_HOME) echo "$DEX_HOME" ;;
DEX_NAMESPACE) echo "dex/v1" ;;
DEX_NETWORK) echo "true" ;;
DEX_REGISTRY) echo "true" ;;
DEX_RUNTIME) echo "v1" ;;
__checkouts) echo "$DEX_HOME/checkouts" ;;
__sources) echo "$DEX_HOME/sources.list" ;;
__sources_url) echo "https://raw.githubusercontent.com/dockerland/dex/master/v1-sources.list" ;;
__defaults) echo "false" ;;
__force) echo "false" ;;
__format) echo "" ;;
__pull) echo "false" ;;
*) echo "unrecognized var: $1" ; retval=1 ;;
esac
}
@test "conf vars prints evaluable output defining APP_VARS" {
reset/vars
eval $($APP conf vars)
for var in "${APP_VARS[@]}"; do
eval "[ -n \"\$var\" ]"
done
}
@test "conf vars prints evaluable output for fish|powershell" {
#@TODO -- implement
skip
}
@test "conf vars respects limiting output to passed variable names" {
reset/vars
eval $($APP conf vars -- DEX_BIN_PREFIX DEX_BIN_DIR )
[ -n "$DEX_BIN_PREFIX" ]
[ -n "$DEX_BIN_DIR" ]
[ -z "$DEX_RUNTIME" ]
}
@test "conf vars reflects current environment settings" {
export DEX_RUNTIME="zzz"
run $APP conf vars -- DEX_RUNTIME
[[ "$output" == *"DEX_RUNTIME=\"zzz\""* ]]
}
@test "conf vars --defaults ignores current environment settings" {
export DEX_BIN_DIR="zzz"
export DEX_BIN_PREFIX="zzz"
export DEX_HOME="$TMPDIR/zzz"
export DEX_NAMESPACE="zzz"
export DEX_NETWORK=false
export DEX_REGISTRY=false
export DEX_RUNTIME="zzz"
eval $($APP conf vars --defaults)
for var in "${APP_VARS[@]}"; do
echo "$var"
#echo $(default/val $var)
#eval "echo \"\$$var\""
eval "[ \"$(default/val $var)\" = \"\$$var\" ]"
done
}
@test "internal vars get initialized to defaults" {
local ivars=(
__checkouts
__sources
__sources_url
__defaults
__force
__pull
__format
)
eval $($APP conf vars -- "${ivars[@]}")
for var in "${ivars[@]}"; do
echo "$var"
#echo $(default/val $var)
#eval "echo \"\$$var\""
eval "[ \"$(default/val $var)\" = \"\$$var\" ]"
done
}