summaryrefslogtreecommitdiffstats
path: root/test/test-stash.sh
blob: 862aef1f10a8bd6b757afc95f0dc48cb3fc82af1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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