aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-30 20:50:18 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-30 20:50:18 +0100
commit3b3c80db30af556d5da7301037bf16782216d0bd (patch)
tree8d4c5dac1a73e9a5bd0af4923982bc84566ffd24 /test
parenta4215743db91c4b7050dfda32a670814a101b773 (diff)
downloadapp.sh-3b3c80db30af556d5da7301037bf16782216d0bd.tar.gz
app.sh-3b3c80db30af556d5da7301037bf16782216d0bd.tar.bz2
app.sh-3b3c80db30af556d5da7301037bf16782216d0bd.tar.xz
app.sh-3b3c80db30af556d5da7301037bf16782216d0bd.zip
bin/app-init:
o Adding -p to mkdir so parent directories are created. libexec/app-resolver-maven: o Not using command expansion to make sure "set -e" works as normal. o Adding a basic check that xmlstartlet has a useful output.
Diffstat (limited to 'test')
-rwxr-xr-xtest/X-it-install-remove.bats45
-rwxr-xr-xtest/app-conf.bats12
-rwxr-xr-xtest/app-init.bats10
-rwxr-xr-xtest/data/app-a/hooks/post-install13
-rwxr-xr-xtest/it-install-remove.bats40
-rwxr-xr-x[-rw-r--r--]test/utils.bash12
6 files changed, 74 insertions, 58 deletions
diff --git a/test/X-it-install-remove.bats b/test/X-it-install-remove.bats
deleted file mode 100755
index 78f4532..0000000
--- a/test/X-it-install-remove.bats
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env bats
-# vim: set filetype=sh:
-
-load utils
-
-@test "install remove roundtrip" {
- mkzip "app-a"
- name="app-a"
- instance="prod"
- a="-n $name -i $instance"
-
- describe "Installing $name/$instance"
- app instance install \
- -r file \
- -u $BATS_TEST_DIRNAME/data/app-a.zip \
- -n $name -i $instance; echo_lines
- [ $status -eq 0 ]
-
- can_not_read ".app/var/pid/$name-$instance.pid"
-
- describe "Setting property"
- app -n $name -i $instance conf set env.TEST_PROPERTY awesome
- [ $status -eq 0 ]
-
- describe "Starting $name/$instance"
- app -n $name -i $instance operate start
- echo_lines
- [ $status -eq 0 ]
- can_read .app/var/pid/$name-$instance.pid
-
- describe "Stopping $name/$instance"
- app -n $name -i $instance operate stop
- [ $status -eq 0 ]
- echo_lines
- can_not_read .app/var/pid/$name-$instance.pid
-
- can_read "$name/$instance/logs/$name.log"
- can_read "$name/$instance/logs/$name.env"
- can_read "$name/$instance/current/foo.conf"
-
- [ "`cat $name/$instance/logs/$name.env`" = "TEST_PROPERTY=awesome" ]
- [ "`cat $name/$instance/current/foo.conf`" = "hello" ]
-
- # TODO: Remove the version
-}
diff --git a/test/app-conf.bats b/test/app-conf.bats
index f85dbab..e805ff3 100755
--- a/test/app-conf.bats
+++ b/test/app-conf.bats
@@ -15,21 +15,25 @@ setup_inner() {
eq '$status' 0
eq '${#lines[*]}' 0
- app conf set g.foo bar; echo_lines
+ app conf set g.FOO bar; echo_lines
eq '$status' 0
app conf; echo_lines
eq '$status' 0
eq '${lines[0]}' "app.bin bin/app-a "
- eq '${lines[1]}' "g.foo bar "
+ eq '${lines[1]}' "g.FOO bar "
eq '${#lines[*]}' 2
- app conf get g.foo; echo_lines
+ app conf get g.FOO; echo_lines
eq '$status' 0
eq '${lines[0]}' "bar"
eq '${#lines[*]}' 1
- app conf delete g.foo; echo_lines
+ app conf get g.foo; echo_lines
+ eq '$status' 0
+ eq '${#lines[*]}' 0
+
+ app conf delete g.FOO; echo_lines
eq '$status' 0
app conf; echo_lines
diff --git a/test/app-init.bats b/test/app-init.bats
index df3919e..2a3e1d8 100755
--- a/test/app-init.bats
+++ b/test/app-init.bats
@@ -20,15 +20,7 @@ load utils
@test "Happy day" {
mkzip app-a
-
- REPO=$BATS_TMPDIR/repo
-
- if [ ! -f $REPO/org/example/app-a/1.0-SNAPSHOT/maven-metadata.xml ]
- then
- mvn deploy:deploy-file -Durl=file://$REPO \
- -Dfile=`echo $APPSH_HOME/test/data/app-a.zip` -DgeneratePom \
- -DgroupId=org.example -DartifactId=app-a -Dversion=1.0-SNAPSHOT -Dpackaging=zip
- fi
+ install_artifact
app init -d my-app maven -r "file://$BATS_TMPDIR/repo" org.example:app-a:1.0-SNAPSHOT; echo_lines
eq '$status' 0
diff --git a/test/data/app-a/hooks/post-install b/test/data/app-a/hooks/post-install
index c548ad7..d4ca67a 100755
--- a/test/data/app-a/hooks/post-install
+++ b/test/data/app-a/hooks/post-install
@@ -4,6 +4,19 @@ set -u
echo "Post install"
+NAME=`basename $APP_HOME`
+
+echo NAME=$NAME
+echo pwd=`pwd`
+set -x
+if [ -d root/etc/$NAME ]
+then
+ find root/etc/$NAME -maxdepth 1 -type f | while read file
+ do
+ cp $file root/
+ done
+fi
+
[ -d ../../logs ] || mkdir ../../logs
ln -s ../../../logs root/logs
diff --git a/test/it-install-remove.bats b/test/it-install-remove.bats
new file mode 100755
index 0000000..96bd2db
--- /dev/null
+++ b/test/it-install-remove.bats
@@ -0,0 +1,40 @@
+#!/usr/bin/env bats
+# vim: set filetype=sh:
+
+load utils
+
+@test "install remove roundtrip" {
+ mkzip "app-a"
+ install_artifact
+
+ describe "Installing app"
+ app init -d my-app/prod maven -r $REPO_URL org.example:app-a:1.0-SNAPSHOT; echo_lines
+ eq '$status' 0
+
+ is_directory "my-app/prod/.app"
+ cd my-app/prod
+
+ describe "Setting property"
+ app conf set env.TEST_PROPERTY awesome; echo_lines
+ eq '$status' 0
+
+ describe "Starting"
+ app start; echo_lines
+ eq '$status' 0
+ can_read .app/pid
+
+ describe "Stopping"
+ app stop
+ eq '$status' 0
+ echo_lines
+ can_not_read .app/pid
+
+ can_read "logs/app-a.log"
+ can_read "logs/app-a.env"
+ can_read "current/foo.conf"
+
+ [ "`cat logs/app-a.env`" = "TEST_PROPERTY=awesome" ]
+ [ "`cat current/foo.conf`" = "hello" ]
+
+ # TODO: Remove the version
+}
diff --git a/test/utils.bash b/test/utils.bash
index 3a9d425..3c3f33f 100644..100755
--- a/test/utils.bash
+++ b/test/utils.bash
@@ -16,6 +16,9 @@ setup() {
mkdir $BATS_TMPDIR/app.sh
cd $BATS_TMPDIR/app.sh
+ REPO=$BATS_TMPDIR/repo
+ REPO_URL="file://$REPO"
+
if [ "`declare -f setup_inner >/dev/null; echo $?`" = 0 ]
then
setup_inner
@@ -36,6 +39,15 @@ mkzip() {
)
}
+install_artifact() {
+ if [ ! -f $REPO/org/example/app-a/1.0-SNAPSHOT/maven-metadata.xml ]
+ then
+ mvn deploy:deploy-file -Durl=$REPO_URL \
+ -Dfile=`echo $APPSH_HOME/test/data/app-a.zip` -DgeneratePom \
+ -DgroupId=org.example -DartifactId=app-a -Dversion=1.0-SNAPSHOT -Dpackaging=zip
+ fi
+}
+
app() {
echo app $@
run $APPSH_HOME/app $@