From 6ce9403be0a09e083e246af186e5aa7bf0273e5a Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 10 May 2017 11:12:09 +0200 Subject: [PATCH] Started writing tests for the install script --- test/install/install.bats | 38 ++++++++++++++++++++++++++++++++++++++ test/run | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/install/install.bats diff --git a/test/install/install.bats b/test/install/install.bats new file mode 100644 index 00000000..fcabe691 --- /dev/null +++ b/test/install/install.bats @@ -0,0 +1,38 @@ +#!/usr/bin/env bats + +load ../test_helper +load ../../lib/composure + +function local_setup { + mkdir -p $BASH_IT + lib_directory="$(cd "$(dirname "$0")" && pwd)" + cp -r $lib_directory/../../* $BASH_IT/ + + # Don't pollute the user's actual $HOME directory + # Use a test home directory instead + export BASH_IT_TEST_CURRENT_HOME="${HOME}" + export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME" + mkdir -p "${BASH_IT_TEST_HOME}" + export HOME="${BASH_IT_TEST_HOME}" +} + +function local_teardown { + export HOME="${BASH_IT_TEST_CURRENT_HOME}" + + rm -rf "${BASH_IT_TEST_HOME}" + + assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}" +} + +@test "install: verify that the install script exists" { + [ -e "$BASH_IT/install.sh" ] +} + +@test "install: run the install script silently" { + skip "Waiting for test to be implemented" + cd "$BASH_IT" + + ./install.sh --silent + + [ -e "$BASH_IT_TEST_HOME/.bash_profile" ] +} diff --git a/test/run b/test/run index 397aec9c..59150a39 100755 --- a/test/run +++ b/test/run @@ -9,4 +9,4 @@ if [ -z "${BASH_IT}" ]; then export BASH_IT=$(cd ${test_directory} && dirname $(pwd)) fi -exec $bats_executable ${CI:+--tap} ${test_directory}/{lib,plugins} +exec $bats_executable ${CI:+--tap} ${test_directory}/{install,lib,plugins}