]> git.scottworley.com Git - pinch/blobdiff - tests/lib/test-setup.sh
Factor out test setup
[pinch] / tests / lib / test-setup.sh
diff --git a/tests/lib/test-setup.sh b/tests/lib/test-setup.sh
new file mode 100644 (file)
index 0000000..12cf525
--- /dev/null
@@ -0,0 +1,26 @@
+set -e
+
+foo_setup() {
+
+  repo_dir="`mktemp -d`"
+  repo="$repo_dir/repo"
+  git init "$repo"
+  (
+    cd "$repo"
+    echo Contents > test-file
+    git add test-file
+    git commit -m 'Commit message'
+  )
+
+  conf="`mktemp`"
+  cat > "$conf" <<EOF
+[foo]
+git_repo = file://$repo
+git_ref = master
+EOF
+
+}
+
+foo_cleanup() {
+  rm -rf "$repo_dir" "$conf"
+}