aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-20 18:09:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-20 20:23:30 +0200
commit11cf17750885324a58a68d237b0ac29bc3a6269b (patch)
tree474da312f12a82629b495b5901c10ea49b08e98c /test
parentd2e3a3795f345fd78ead2cf06b1134b46f9d4bc4 (diff)
downloadapp.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.tar.gz
app.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.tar.bz2
app.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.tar.xz
app.sh-11cf17750885324a58a68d237b0ac29bc3a6269b.zip
o Making all app-conf options except import use <-l location>.
o Setting $HOME to the temporary area when testing. o Adding test docs for app-conf.
Diffstat (limited to 'test')
-rwxr-xr-xtest/app-cat-conf.bats23
-rwxr-xr-xtest/app-conf.bats106
-rwxr-xr-xtest/app-init.bats6
-rw-r--r--test/utils.bash24
4 files changed, 93 insertions, 66 deletions
diff --git a/test/app-cat-conf.bats b/test/app-cat-conf.bats
index 62309a5..2acdd99 100755
--- a/test/app-cat-conf.bats
+++ b/test/app-cat-conf.bats
@@ -65,7 +65,7 @@ foo.wat=bar" ]]
eq '${#lines[*]}' 1
}
-@test "uses \$APPSH_DEFAULT_CONFIG, check order" {
+@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
eq '${lines[0]}' "foo.bar=baz"
@@ -73,7 +73,7 @@ foo.wat=bar" ]]
eq '${#lines[*]}' 2
}
-@test "app-cat-conf read from installation's, user's and then app's config" {
+@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
@@ -83,15 +83,24 @@ foo.wat=bar" ]]
eq '${#lines[*]}' 2
}
-# With home directory, outside app
-@test "./app conf - should read user's conf too, in app" {
+@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
- eq '${lines[0]}' "foo.bar=2"
- eq '${lines[1]}' "foo.baz=3"
- eq '${lines[2]}' "foo.foo=2"
+ eq '${lines[0]}' "foo.bar=2"
+ eq '${lines[1]}' "foo.baz=3"
+ eq '${lines[2]}' "foo.foo=2"
eq '${#lines[*]}' 3
}
+
+@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
+ eq '${lines[0]}' "foo.bar=1"
+ eq '${lines[1]}' "foo.foo=2"
+ eq '${#lines[*]}' 2
+}
diff --git a/test/app-conf.bats b/test/app-conf.bats
index c95a133..d1a2b18 100755
--- a/test/app-conf.bats
+++ b/test/app-conf.bats
@@ -10,34 +10,29 @@ setup_inner() {
}
@test "./app conf - happy day" {
- app conf; echo_lines
+ app conf
echo "app.bin=bin/app-a" > .app/config
eq '$status' 0
eq '${#lines[*]}' 0
- app conf set g.FOO bar; echo_lines
- eq '$status' 0
+ app conf set g.FOO bar
- app conf; echo_lines
- eq '$status' 0
+ app conf
eq '${lines[0]}' "app.bin bin/app-a "
eq '${lines[1]}' "g.FOO bar "
eq '${#lines[*]}' 2
- app conf get g.FOO; echo_lines
- eq '$status' 0
+ app conf get g.FOO
eq '${lines[0]}' "bar"
eq '${#lines[*]}' 1
- app conf get g.foo; echo_lines
- eq '$status' 0
+ app conf get g.foo
eq '${#lines[*]}' 0
- app conf delete g.FOO; echo_lines
- eq '$status' 0
+ app conf delete g.FOO
+ eq '${#lines[*]}' 0
- app conf; echo_lines
- eq '$status' 0
+ app conf
eq '${lines[0]}' "app.bin bin/app-a "
eq '${#lines[*]}' 1
}
@@ -45,82 +40,82 @@ setup_inner() {
@test "./app conf - defaults to 'list'" {
echo "app.bin=bin/app-a" > .app/config
- app conf; echo_lines
- eq '$status' 0
+ app conf
eq '${#lines[*]}' 1
eq '${lines[0]}' "app.bin bin/app-a "
}
@test "./app conf wat" {
- app conf wat; echo_lines
- eq '$status' 1
+ check_status=no
+ app conf wat
eq '${lines[0]}' "Unknown command: wat"
}
@test "./app conf list" {
echo "app.bin=bin/app-a" > .app/config
- app conf; echo_lines
- eq '$status' 0
+ app conf
eq '${#lines[*]}' 1
eq '${lines[0]}' "app.bin bin/app-a "
- app conf list; echo_lines
- eq '$status' 0
+ app conf list
eq '${#lines[*]}' 1
eq '${lines[0]}' "app.bin bin/app-a "
- app conf list foo; echo_lines
+ check_status=no
+ app conf list foo
eq '$status' 1
}
-#@test "./app conf list-group" {
-# app conf set mygroup a 1
-# eq '$status' 0
-# app conf set mygroup b 1
-# eq '$status' 0
-# app conf set mygroup c 2
-# eq '$status' 0
-# app conf set othergroup a 1
-# eq '$status' 0
-#
-# app conf list; echo_lines
-# eq '$status' 0
-# app conf list-group mygroup; echo_lines
-# eq '$status' 0
-# eq '${lines[0]}' "mygroup.a 1 "
-# eq '${lines[1]}' "mygroup.b 1 "
-# eq '${lines[2]}' "mygroup.c 2 "
-# eq '${#lines[*]}' 3
-#}
+@test "./app conf list - with duplicate entries" {
+ echo "foo.bar=awesome" > .app/config
+ echo "foo.bar=awesome" >> .app/config
+
+ app conf list
+ eq '${lines[0]}' "foo.bar awesome "
+ eq '${#lines[*]}' 1
+}
+
+@test "./app conf list in non-app dir" {
+ mkdir wat
+ cd wat
+ app conf list
+ eq '${#lines[*]}' 0
+}
@test "./app conf set" {
echo "app.bin=bin/app-a" > .app/config
- app conf set group; echo_lines
+ check_status=no
+ app conf set group
eq '$status' 1
- app conf set group.foo; echo_lines
+ check_status=no
+ app conf set group.foo
eq '$status' 1
- app conf set group.foo bar; echo_lines
- eq '$status' 0
+ app conf set group.foo bar
eq '${#lines[*]}' 0
- app conf; echo_lines
- eq '$status' 0
+ app conf
eq '${lines[0]}' "app.bin bin/app-a "
eq '${lines[1]}' "group.foo bar "
eq '${#lines[*]}' 2
}
-@test "./app conf list - with duplicate entries" {
- echo "foo.bar=awesome" > .app/config
- echo "foo.bar=awesome" >> .app/config
+@test "./app conf -l app set" {
+ echo > .app/config
+ app conf -l app set a.x 2
+ app_libexec app-cat-conf
+ eq '${lines[0]}' "a.x=2"
+ eq '${#lines[*]}' 1
+}
- app conf list; echo_lines
- eq '$status' 0
- eq '${lines[0]}' "foo.bar awesome "
+@test "./app conf -l user set" {
+ echo > .app/config
+ app conf -l user set a.x 3
+ app_libexec app-cat-conf -l user
+ eq '${lines[0]}' "a.x=3"
eq '${#lines[*]}' 1
}
@@ -129,12 +124,11 @@ setup_inner() {
echo "foo.baz=1" > config-b
echo "foo.bar=2" >> config-b
- app conf import config-b; echo_lines
- eq '$status' 0
+ app conf import config-b
eq '${lines[0]}' "Importing config from config-b"
eq '${#lines[*]}' 1
- app_libexec app-cat-conf; echo_lines
+ app_libexec app-cat-conf
eq '${lines[0]}' "foo.bar=2"
eq '${lines[1]}' "foo.baz=1"
eq '${#lines[*]}' 2
diff --git a/test/app-init.bats b/test/app-init.bats
index db681a1..3f58890 100755
--- a/test/app-init.bats
+++ b/test/app-init.bats
@@ -22,7 +22,7 @@ load utils
mkzip app-a
install_artifact
- app init -d my-app maven -r "file://$BATS_TMPDIR/repo" org.example:app-a:1.0-SNAPSHOT; echo_lines
+ app init -d my-app maven -r "file://$BATS_TMPDIR/repo" org.example:app-a:1.0-SNAPSHOT
eq '$status' 0
eq '${lines[0]}' "Resolving Maven version 1.0-SNAPSHOT..."
match '${lines[1]}' "Resolved version to 1.0-*"
@@ -42,8 +42,8 @@ load utils
mkzip app-a
install_artifact 1.0
- app init -d my-app maven -r "file://$BATS_TMPDIR/repo" org.example:app-a:1.0; echo_lines
- eq '$status' 0
+ app conf -l user set maven.repo "file://$BATS_TMPDIR/repo"
+ app init -d my-app maven org.example:app-a:1.0
match '${lines[0]}' "Resolved version to 1.0"
match '${lines[1]}' "Downloading org.example:app-a:1.0-*"
eq '${lines[2]}' "Unpacking..."
diff --git a/test/utils.bash b/test/utils.bash
index 26be39d..88dd889 100644
--- a/test/utils.bash
+++ b/test/utils.bash
@@ -15,6 +15,11 @@ setup() {
rm -rf $BATS_TMPDIR/app.sh
mkdir $BATS_TMPDIR/app.sh
+
+ HOME=$BATS_TMPDIR/app.sh-home
+ mkdir -p $HOME
+ rm -f $HOME/.appconfig
+
cd $BATS_TMPDIR/app.sh
REPO=$BATS_TMPDIR/repo
@@ -49,9 +54,19 @@ install_artifact() {
-DgroupId=org.example -DartifactId=app-a -Dversion=$version -Dpackaging=zip
}
+check_status=yes
+
app() {
echo app $@
run $APPSH_HOME/app $@
+ echo_lines
+
+ if [ "$check_status" = yes ]
+ then
+ eq '$status' 0
+ fi
+
+ check_status=yes
}
app_libexec() {
@@ -60,6 +75,15 @@ app_libexec() {
echo libexec/$@
shift
run "$x" $@
+
+ echo_lines
+
+ if [ "$check_status" = yes ]
+ then
+ eq '$status' 0
+ fi
+
+ check_status=yes
}
fix_path_uname=`uname -s`