summaryrefslogtreecommitdiffstats
path: root/test-files.sh
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-02-17 21:09:21 +0000
committerMichael Allen <michael@michaelallen.io>2015-02-17 21:09:58 +0000
commit01538d46bac4d2607ad01d04548085f6918ba4d0 (patch)
tree6d9b963502344d320b9d976108d4d43a7c6ae019 /test-files.sh
parenta333df6a1a61f0c0e4bc6d774ceff4e9f6bd61f8 (diff)
downloadgit-sonar-01538d46bac4d2607ad01d04548085f6918ba4d0.tar.gz
git-sonar-01538d46bac4d2607ad01d04548085f6918ba4d0.zip
add functions for conflicted changes
Diffstat (limited to 'test-files.sh')
-rwxr-xr-xtest-files.sh124
1 files changed, 124 insertions, 0 deletions
diff --git a/test-files.sh b/test-files.sh
index 22a1966..1966d03 100755
--- a/test-files.sh
+++ b/test-files.sh
@@ -30,6 +30,46 @@ test_untracked_files() {
rm_tmp
}
+test_unstaged_modified_files() {
+ cd_to_tmp
+ git init --quiet
+
+ assertEquals "0" "$(unstaged_modified_changes)"
+
+ touch foo
+ touch bar
+ git add .
+ git commit -m "foo and bar" >/dev/null
+
+ echo "foo" >> foo
+ assertEquals "1" "$(unstaged_modified_changes)"
+
+ echo "bar" >> bar
+ assertEquals "2" "$(unstaged_modified_changes)"
+
+ rm_tmp
+}
+
+test_unstaged_deleted_files() {
+ cd_to_tmp
+ git init --quiet
+
+ assertEquals "0" "$(unstaged_deleted_changes)"
+
+ touch foo
+ touch bar
+ git add .
+ git commit -m "foo and bar" >/dev/null
+
+ rm foo
+ assertEquals "1" "$(unstaged_deleted_changes)"
+
+ rm bar
+ assertEquals "2" "$(unstaged_deleted_changes)"
+
+ rm_tmp
+}
+
test_staged_added_files() {
cd_to_tmp
git init --quiet
@@ -113,4 +153,88 @@ test_staged_renamed_files() {
rm_tmp
}
+test_conflicted_both_changes() {
+ cd_to_tmp
+ git init --quiet
+
+ git checkout -b foo --quiet
+ echo "foo" >> foo
+ git add .
+ git commit -m "foo" --quiet
+
+ git checkout -b foo2 --quiet
+ echo "bar" >> foo
+ git add .
+ git commit -m "bar" --quiet
+
+ git checkout foo --quiet
+ echo "foo2" >> foo
+ git add .
+ git commit -m "foo2" --quiet
+
+ assertEquals "0" "$(conflicted_both_changes)"
+
+ git merge foo2 >/dev/null
+
+ assertEquals "1" "$(conflicted_both_changes)"
+
+ rm_tmp
+}
+
+test_conflicted_them_changes() {
+ cd_to_tmp
+ git init --quiet
+
+ git checkout -b foo --quiet
+ echo "foo" >> foo
+ git add .
+ git commit -m "foo" --quiet
+
+ git checkout -b foo2 --quiet
+ rm foo
+ git add .
+ git commit -m "delete foo" --quiet
+
+ git checkout foo --quiet
+ echo "foo2" >> foo
+ git add .
+ git commit -m "foo2" --quiet
+
+ assertEquals "0" "$(conflicted_by_them_changes)"
+
+ git merge foo2 >/dev/null
+
+ assertEquals "1" "$(conflicted_by_them_changes)"
+
+ rm_tmp
+}
+
+test_conflicted_us_changes() {
+ cd_to_tmp
+ git init --quiet
+
+ git checkout -b foo --quiet
+ echo "foo" >> foo
+ git add .
+ git commit -m "foo" --quiet
+
+ git checkout -b foo2 --quiet
+ echo "bar" >> foo
+ git add .
+ git commit -m "bar" --quiet
+
+ git checkout foo --quiet
+ rm foo
+ git add .
+ git commit -m "delete foo" --quiet
+
+ assertEquals "0" "$(conflicted_by_us_changes)"
+
+ git merge foo2 >/dev/null
+
+ assertEquals "1" "$(conflicted_by_us_changes)"
+
+ rm_tmp
+}
+
. ./shunit/shunit2