aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/app-help.bats (renamed from test/02-app-help.bats)4
-rwxr-xr-xtest/app-install.bats22
-rw-r--r--test/data/app-a.zipbin0 -> 715 bytes
-rw-r--r--test/data/app-a/root/bin/app-a0
-rw-r--r--test/data/app-a/scripts/postinstall3
-rwxr-xr-xtest/help.bats (renamed from test/01-help.bats)2
-rw-r--r--test/utils.bash8
7 files changed, 36 insertions, 3 deletions
diff --git a/test/02-app-help.bats b/test/app-help.bats
index 460762f..68f88e3 100755
--- a/test/02-app-help.bats
+++ b/test/app-help.bats
@@ -1,5 +1,5 @@
#!/usr/bin/env bats
-# vim: set filetype=sh :
+# vim: set filetype=sh:
load utils
@@ -27,7 +27,7 @@ load utils
app app list-versions; echo_lines
[ $status -eq $exit_usage ]
[ $(expr "${lines[0]}" : "usage: list-versions .*") -ne 0 ]
- [ ${#lines[*]} == 2 ]
+ [ ${#lines[*]} == 1 ]
}
@test "./app app set-current" {
diff --git a/test/app-install.bats b/test/app-install.bats
new file mode 100755
index 0000000..8f164bc
--- /dev/null
+++ b/test/app-install.bats
@@ -0,0 +1,22 @@
+#!/usr/bin/env bats
+# vim: set filetype=sh:
+
+load utils
+
+@test "./app app install" {
+ zip_app_a
+ app app install \
+ -r file \
+ -u $BATS_TEST_DIRNAME/data/app-a.zip \
+ -n app-a -i prod
+
+ echo_lines
+ [ $status -eq $exit_usage ]
+ [ "$output" = "Creating instance 'prod' for 'app-a'
+Unpacking...
+Running postinstall...
+Hello World!
+Postinstall completed successfully
+Changing current symlink" ]
+ [ ${#lines[*]} == 6 ]
+}
diff --git a/test/data/app-a.zip b/test/data/app-a.zip
new file mode 100644
index 0000000..7562ab6
--- /dev/null
+++ b/test/data/app-a.zip
Binary files differ
diff --git a/test/data/app-a/root/bin/app-a b/test/data/app-a/root/bin/app-a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/data/app-a/root/bin/app-a
diff --git a/test/data/app-a/scripts/postinstall b/test/data/app-a/scripts/postinstall
new file mode 100644
index 0000000..cd16289
--- /dev/null
+++ b/test/data/app-a/scripts/postinstall
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello World!"
diff --git a/test/01-help.bats b/test/help.bats
index 8bd4fd7..eba4eeb 100755
--- a/test/01-help.bats
+++ b/test/help.bats
@@ -1,5 +1,5 @@
#!/usr/bin/env bats
-# vim: set filetype=sh :
+# vim: set filetype=sh:
load utils
diff --git a/test/utils.bash b/test/utils.bash
index eacabe8..eaa2580 100644
--- a/test/utils.bash
+++ b/test/utils.bash
@@ -19,6 +19,14 @@ setup() {
ln -s $APPSH
}
+zip_app_a() {
+(
+ cd $BATS_TEST_DIRNAME/data/app-a
+ rm -f ../app-a.zip
+ zip -qr ../app-a.zip *
+)
+}
+
app() {
run ./app "$@"
}