From 157f4e79aaa8b8b14f9fcfe050f1f7ee5c1857eb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 09:17:22 +0200 Subject: [PATCH] test setup: Prepare store directory before starting tests --- tests/utils.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/utils.sh b/tests/utils.sh index 6480337d..57c5b079 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -47,10 +47,16 @@ cat_entry() { } reset_store() { + rm -rf "${STORE}"/.git rm -r "${STORE}" } call_test() { + prepare_store_directory || { + err "Preparing store directory failed" + exit 1 + } + out "-- TESTING: '$1' --" $1 result=$? @@ -63,6 +69,27 @@ call_test() { success "-- SUCCESS: '$1' --" } +__git() { + out "Calling git: $*" + git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git $* +} + +__git_commit() { + out "Calling git-commit: $*" + git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git commit -m "$*" +} + +prepare_store_directory() { + out "Preparing /tmp/store" + mkdir -p /tmp/store/ &&\ + touch /tmp/store/.gitkeep &&\ + __git init &&\ + __git config --local user.email "imag@imag-pim.org" &&\ + __git config --local user.name "Imag CI" &&\ + __git add .gitkeep &&\ + __git_commit 'Initial commit: .gitkeep' +} + invoke_tests() { out "Invoking tests." if [[ ! -z "$INVOKE_TEST" ]]; then