From a3db63fa62abee81e866fc2397c9302486a09cbb Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 14 Oct 2012 09:08:56 +0200 Subject: o More tests. --- .app/lib/app-app | 1 - test/01-help.bats | 17 ---------------- test/02-app-help.bats | 38 ------------------------------------ test/app-help.bats | 38 ++++++++++++++++++++++++++++++++++++ test/app-install.bats | 22 +++++++++++++++++++++ test/data/app-a.zip | Bin 0 -> 715 bytes test/data/app-a/root/bin/app-a | 0 test/data/app-a/scripts/postinstall | 3 +++ test/help.bats | 17 ++++++++++++++++ test/utils.bash | 8 ++++++++ 10 files changed, 88 insertions(+), 56 deletions(-) delete mode 100755 test/01-help.bats delete mode 100755 test/02-app-help.bats create mode 100755 test/app-help.bats create mode 100755 test/app-install.bats create mode 100644 test/data/app-a.zip create mode 100644 test/data/app-a/root/bin/app-a create mode 100644 test/data/app-a/scripts/postinstall create mode 100755 test/help.bats diff --git a/.app/lib/app-app b/.app/lib/app-app index 130244e..ae77298 100644 --- a/.app/lib/app-app +++ b/.app/lib/app-app @@ -354,7 +354,6 @@ method_list_versions_usage() { fi echo "usage: list-versions -n name -i instance [-P]" >&2 - echo " -P - parsable output" >&2 exit 1 } diff --git a/test/01-help.bats b/test/01-help.bats deleted file mode 100755 index 8bd4fd7..0000000 --- a/test/01-help.bats +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bats -# vim: set filetype=sh : - -load utils - -@test "./app" { - app; echo_lines - [ $status -eq $exit_usage_wrong ] - [ $(expr "${lines[0]}" : "usage: ./app .*") -ne 0 ] -} - -@test "./app foo" { - app foo; echo_lines - [ $status -eq $exit_usage_wrong ] - [ "${lines[0]}" = "Error: No such method group: foo" ] - [ $(expr "${lines[1]}" : "usage: ./app .*") -ne 0 ] -} diff --git a/test/02-app-help.bats b/test/02-app-help.bats deleted file mode 100755 index 460762f..0000000 --- a/test/02-app-help.bats +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bats -# vim: set filetype=sh : - -load utils - -@test "./app app" { - app app; echo_lines - [ $status -eq $exit_usage_wrong ] - [ $(expr "${lines[0]}" : "usage: ./app app .*") -ne 0 ] - [ ${#lines[*]} == 6 ] -} - -@test "./app app install" { - app app install; echo_lines - [ $status -eq $exit_usage ] - [ $(expr "${lines[0]}" : "usage: install .*") -ne 0 ] - [ ${#lines[*]} == 6 ] -} - -@test "./app app list" { - app app list; echo_lines - [ $status -eq 0 ] - [ ${#lines[*]} == 0 ] -} - -@test "./app app list-versions" { - app app list-versions; echo_lines - [ $status -eq $exit_usage ] - [ $(expr "${lines[0]}" : "usage: list-versions .*") -ne 0 ] - [ ${#lines[*]} == 2 ] -} - -@test "./app app set-current" { - app app "set-current"; echo_lines - [ $status -eq $exit_usage ] - [ $(expr "${lines[0]}" : "usage: set-current .*") -ne 0 ] - [ ${#lines[*]} == 1 ] -} diff --git a/test/app-help.bats b/test/app-help.bats new file mode 100755 index 0000000..68f88e3 --- /dev/null +++ b/test/app-help.bats @@ -0,0 +1,38 @@ +#!/usr/bin/env bats +# vim: set filetype=sh: + +load utils + +@test "./app app" { + app app; echo_lines + [ $status -eq $exit_usage_wrong ] + [ $(expr "${lines[0]}" : "usage: ./app app .*") -ne 0 ] + [ ${#lines[*]} == 6 ] +} + +@test "./app app install" { + app app install; echo_lines + [ $status -eq $exit_usage ] + [ $(expr "${lines[0]}" : "usage: install .*") -ne 0 ] + [ ${#lines[*]} == 6 ] +} + +@test "./app app list" { + app app list; echo_lines + [ $status -eq 0 ] + [ ${#lines[*]} == 0 ] +} + +@test "./app app list-versions" { + app app list-versions; echo_lines + [ $status -eq $exit_usage ] + [ $(expr "${lines[0]}" : "usage: list-versions .*") -ne 0 ] + [ ${#lines[*]} == 1 ] +} + +@test "./app app set-current" { + app app "set-current"; echo_lines + [ $status -eq $exit_usage ] + [ $(expr "${lines[0]}" : "usage: set-current .*") -ne 0 ] + [ ${#lines[*]} == 1 ] +} 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 Binary files /dev/null and b/test/data/app-a.zip 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 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/help.bats b/test/help.bats new file mode 100755 index 0000000..eba4eeb --- /dev/null +++ b/test/help.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +# vim: set filetype=sh: + +load utils + +@test "./app" { + app; echo_lines + [ $status -eq $exit_usage_wrong ] + [ $(expr "${lines[0]}" : "usage: ./app .*") -ne 0 ] +} + +@test "./app foo" { + app foo; echo_lines + [ $status -eq $exit_usage_wrong ] + [ "${lines[0]}" = "Error: No such method group: foo" ] + [ $(expr "${lines[1]}" : "usage: ./app .*") -ne 0 ] +} 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 "$@" } -- cgit v1.2.3