summaryrefslogtreecommitdiffstats
path: root/test/test-stash.sh
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2021-07-20 20:10:34 -0400
committerMalfurious <m@lfurio.us>2021-07-20 20:10:34 -0400
commit0173bdcf5bc2bb97bd125679ee25e12ed8be544f (patch)
treed2381fa960c55dfcfda4ae0b87396ca0f7fc24c7 /test/test-stash.sh
parent3d5a9a7c893f3505216d00348e94ccf1aa5d9084 (diff)
downloadgit-sonar-0173bdcf5bc2bb97bd125679ee25e12ed8be544f.tar.gz
git-sonar-0173bdcf5bc2bb97bd125679ee25e12ed8be544f.zip
Move test files to subdirectory
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'test/test-stash.sh')
-rwxr-xr-xtest/test-stash.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/test-stash.sh b/test/test-stash.sh
new file mode 100755
index 0000000..862aef1
--- /dev/null
+++ b/test/test-stash.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+scriptDir="$(cd "$(dirname "$0")"; pwd)"
+
+source "$scriptDir/sonar-base.sh"
+
+tmpfile=""
+
+cd_to_tmp() {
+ tmpfile="/tmp/git-prompt-tests-$(time_now)$1"
+ mkdir -p "$tmpfile"
+ cd "$tmpfile"
+}
+
+rm_tmp() {
+ cd $scriptDir
+ rm -rf /tmp/git-prompt-tests*
+}
+
+test_unstashed_status() {
+ cd_to_tmp
+ git init --quiet
+
+ assertEquals "0" "$(stashed_status)"
+
+ rm_tmp
+}
+
+test_stashed_status() {
+ cd_to_tmp
+ git init --quiet
+
+ touch foo
+ git add --all
+ git commit -m "Initial commit" >/dev/null
+ echo "test">foo
+ git stash > /dev/null
+ assertEquals "1" "$(stashed_status)"
+
+ echo "test2">foo
+ git stash > /dev/null
+ assertEquals "2" "$(stashed_status)"
+
+ git stash drop > /dev/null
+ assertEquals "1" "$(stashed_status)"
+
+
+ rm_tmp
+}
+
+. ./shunit/shunit2