aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-26 17:44:19 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-26 17:48:45 +0200
commit165d20eebc587f21f0409850b8e522c7a25979e3 (patch)
treefb127d7270b5a2f5152ab1dddeac306e38850c93 /test
parent2474a9e50e5d21ed6b3fd825d9fe565b79f62014 (diff)
downloadapp.sh-165d20eebc587f21f0409850b8e522c7a25979e3.tar.gz
app.sh-165d20eebc587f21f0409850b8e522c7a25979e3.tar.bz2
app.sh-165d20eebc587f21f0409850b8e522c7a25979e3.tar.xz
app.sh-165d20eebc587f21f0409850b8e522c7a25979e3.zip
app-cat-conf: Removing -n argument, adding -k and -g for 'key' and
'group' lookups.
Diffstat (limited to 'test')
-rwxr-xr-xtest/app-cat-conf.bats71
1 files changed, 31 insertions, 40 deletions
diff --git a/test/app-cat-conf.bats b/test/app-cat-conf.bats
index 2acdd99..c1fd09b 100755
--- a/test/app-cat-conf.bats
+++ b/test/app-cat-conf.bats
@@ -5,11 +5,11 @@ load utils
setup_inner() {
export APPSH_DEFAULT_CONFIG=/dev/null
+ cd $APPSH_HOME/test/data/app-cat-conf
}
@test "app-cat-conf" {
- app_libexec app-cat-conf -f $APPSH_HOME/test/data/app-cat-conf/config-1
- echo_lines
+ app_libexec app-cat-conf -f config-1
eq '${lines[0]}' "baz.kiz=zap"
eq '${lines[1]}' "baz.wat=baz"
eq '${lines[2]}' "foo.bar=wat"
@@ -18,77 +18,62 @@ setup_inner() {
eq '${#lines[*]}' 5
}
+@test "app-cat-conf -k baz.wat" {
+ app_libexec app-cat-conf -f config-1 -k baz.wat
+ eq '${lines[0]}' "baz.wat=baz"
+ eq '${#lines[*]}' 1
+}
+
@test "app-cat-conf -g baz" {
- app_libexec app-cat-conf -f $APPSH_HOME/test/data/app-cat-conf/config-1 -n "baz\..*"
- echo_lines
+ app_libexec app-cat-conf -f config-1 -g baz
eq '${lines[0]}' "baz.kiz=zap"
eq '${lines[1]}' "baz.wat=baz"
eq '${#lines[*]}' 2
}
-@test "app-cat-conf -k wat" {
- app_libexec app-cat-conf -f $APPSH_HOME/test/data/app-cat-conf/config-1 -n ".*\.wat"
- echo_lines
- eq '${lines[0]}' "baz.wat=baz"
- eq '${lines[1]}' "foo.wat=foo"
- eq '${#lines[*]}' 2
-}
-
-@test "app-cat-conf -g baz -k wat" {
- app_libexec app-cat-conf -f $APPSH_HOME/test/data/app-cat-conf/config-1 -n "baz\.wat"
- echo_lines
- eq '${lines[0]}' "baz.wat=baz"
- eq '${#lines[*]}' 1
-}
-
@test "app-cat-conf can use stdin and multiple files" {
- x=$(cat $APPSH_HOME/test/data/app-cat-conf/config-3 | \
- $APPSH_HOME/libexec/app-cat-conf -D -f - -f $APPSH_HOME/test/data/app-cat-conf/config-2)
+ x=$(cat config-3 | \
+ $APPSH_HOME/libexec/app-cat-conf -D -f - -f config-2)
[[ $x == "foo.bar=wat
foo.wat=bar" ]]
}
@test "app-cat-conf read multiple files, last file wins" {
app_libexec app-cat-conf \
- -f $APPSH_HOME/test/data/app-cat-conf/config-2 \
- -f $APPSH_HOME/test/data/app-cat-conf/config-4
- echo_lines
+ -f config-2 \
+ -f config-4
eq '${lines[0]}' "foo.bar=foo"
eq '${#lines[*]}' 1
}
@test "uses \$APPSH_DEFAULT_CONFIG" {
- APPSH_DEFAULT_CONFIG=$APPSH_HOME/test/data/app-cat-conf/config-2
+ APPSH_DEFAULT_CONFIG=`pwd`/config-2
app_libexec app-cat-conf -f /dev/null
- echo_lines
eq '${lines[0]}' "foo.bar=wat"
eq '${#lines[*]}' 1
}
@test "uses \$APPSH_DEFAULT_CONFIG, with lowest priority" {
- app_libexec app-cat-conf -f $APPSH_HOME/test/data/app-cat-conf/config-3
- echo_lines
+ app_libexec app-cat-conf -f config-3
eq '${lines[0]}' "foo.bar=baz"
eq '${lines[1]}' "foo.wat=bar"
eq '${#lines[*]}' 2
}
@test "app-cat-conf - read installation's and user's config when outside app" {
- HOME=$APPSH_HOME/test/data/app-cat-conf/home
- APPSH_DEFAULT_CONFIG=$APPSH_HOME/test/data/app-cat-conf/config-2
- app_libexec app-cat-conf; echo_lines
- eq '$status' 0
+ HOME=`pwd`/home
+ APPSH_DEFAULT_CONFIG=config-2
+ app_libexec app-cat-conf
eq '${lines[0]}' "foo.bar=1"
eq '${lines[1]}' "foo.foo=2"
eq '${#lines[*]}' 2
}
@test "app-cat-conf - read \$HOME/.appconfig and .app/config when inside app" {
- HOME=$APPSH_HOME/test/data/app-cat-conf/home
- APPSH_DEFAULT_CONFIG=$APPSH_HOME/test/data/app-cat-conf/config-2
- cd $APPSH_HOME/test/data/app-cat-conf/my-app
- app_libexec app-cat-conf; echo_lines
- eq '$status' 0
+ HOME=`pwd`/home
+ APPSH_DEFAULT_CONFIG=`pwd`/config-2
+ cd my-app
+ app_libexec app-cat-conf
eq '${lines[0]}' "foo.bar=2"
eq '${lines[1]}' "foo.baz=3"
eq '${lines[2]}' "foo.foo=2"
@@ -97,10 +82,16 @@ foo.wat=bar" ]]
@test "app-cat-conf -l u - read only \$HOME/.appconfig even when in an app" {
HOME=$APPSH_HOME/test/data/app-cat-conf/home
- cd $APPSH_HOME/test/data/app-cat-conf/my-app
- app_libexec app-cat-conf -l u; echo_lines
- eq '$status' 0
+ cd my-app
+ app_libexec app-cat-conf -l u
eq '${lines[0]}' "foo.bar=1"
eq '${lines[1]}' "foo.foo=2"
eq '${#lines[*]}' 2
}
+
+@test "app-cat-conf; extra arguments" {
+ check_status=no
+ app_libexec app-cat-conf zoot
+ eq '$status' 1
+ eq '${#lines[*]}' 1
+}