diff options
author | Michael Allen <michael@michaelallen.io> | 2015-02-17 21:09:21 +0000 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-02-17 21:09:58 +0000 |
commit | 01538d46bac4d2607ad01d04548085f6918ba4d0 (patch) | |
tree | 6d9b963502344d320b9d976108d4d43a7c6ae019 /test-files.sh | |
parent | a333df6a1a61f0c0e4bc6d774ceff4e9f6bd61f8 (diff) | |
download | git-sonar-01538d46bac4d2607ad01d04548085f6918ba4d0.tar.gz git-sonar-01538d46bac4d2607ad01d04548085f6918ba4d0.zip |
add functions for conflicted changes
Diffstat (limited to 'test-files.sh')
-rwxr-xr-x | test-files.sh | 124 |
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 |