From 5aa525caae7610721b5da7daadf633e0df1bec5b Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 16 Jun 2020 09:25:07 +0200 Subject: [PATCH] Refactored setup/teardown --- test/themes/base.theme.svn.bats | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/test/themes/base.theme.svn.bats b/test/themes/base.theme.svn.bats index c358e404..0a525c4a 100644 --- a/test/themes/base.theme.svn.bats +++ b/test/themes/base.theme.svn.bats @@ -20,9 +20,16 @@ function local_setup { -mindepth 1 -maxdepth 1 \ -exec cp -r {} "$BASH_IT/" \; fi + + export OLD_PATH="$PATH" } -setup_repo() { +function local_teardown { + export PATH="$OLD_PATH" + unset OLD_PATH +} + +function setup_repo { upstream="$(mktemp -d)" pushd "$upstream" > /dev/null # Create a dummy SVN folder - this will not work with an actual `svn` command, @@ -32,22 +39,16 @@ setup_repo() { echo "$upstream" } -setup_svn_path() { +function setup_svn_path { local svn_path="$1" # Make sure that the requested SVN script is available assert_file_exist "$svn_path/svn" - export OLD_PATH="$PATH" # Make sure that the requested SVN script is on the path export PATH="$svn_path:/usr/bin:/bin:/usr/sbin" } -reset_svn_path() { - export PATH="$OLD_PATH" - unset OLD_PATH -} - @test 'themes base: SVN: detect SVN repo' { repo="$(setup_repo)" pushd "$repo" @@ -60,8 +61,6 @@ reset_svn_path() { scm # Make sure that the SVN command is used assert_equal "$SCM" "$SCM_SVN" - - reset_svn_path } @test 'themes base: SVN: detect SVN repo even from a subfolder' { @@ -79,8 +78,6 @@ reset_svn_path() { scm # Make sure that the SVN command is used assert_equal "$SCM" "$SCM_SVN" - - reset_svn_path } @test 'themes base: SVN: no SCM if no .svn folder can be found' { @@ -97,8 +94,6 @@ reset_svn_path() { scm # Make sure that the SVN command is used assert_equal "$SCM" "$SCM_NONE" - - reset_svn_path } @test 'themes base: SVN: ignore SVN repo when using broken SVN command' { @@ -113,8 +108,6 @@ reset_svn_path() { scm # Make sure that the SVN command is not used assert_equal "$SCM" "$SCM_NONE" - - reset_svn_path } @test 'themes base: SVN: ignore SVN repo even from a subfolder when using a broken SVN' { @@ -132,6 +125,4 @@ reset_svn_path() { scm # Make sure that the SVN command is used assert_equal "$SCM" "$SCM_NONE" - - reset_svn_path }