summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-09-08 09:17:22 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-09-08 14:23:10 +0200
commit157f4e79aaa8b8b14f9fcfe050f1f7ee5c1857eb (patch)
treee216ccaf8a15f04b692647599416d40bfb8538d4 /tests
parent566c4633836bf23de2ba197eae4dd9b3112828b5 (diff)
test setup: Prepare store directory before starting tests
Diffstat (limited to 'tests')
-rw-r--r--tests/utils.sh27
1 files changed, 27 insertions, 0 deletions
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