summaryrefslogtreecommitdiffstats
path: root/tests/units
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 14:37:05 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 14:37:05 -0800
commitb81ee9305f418209ba0d77fbb7b47b23d4b121ca (patch)
treef4bef02a3befcbe06be85ff8507cb18242df5f40 /tests/units
parentabcb1453e210beb6de70a69d3501cf842b38636e (diff)
downloadthird_party-ruby-git-b81ee9305f418209ba0d77fbb7b47b23d4b121ca.zip
third_party-ruby-git-b81ee9305f418209ba0d77fbb7b47b23d4b121ca.tar.gz
third_party-ruby-git-b81ee9305f418209ba0d77fbb7b47b23d4b121ca.tar.xz
added merging functions
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/test_branch.rb4
-rw-r--r--tests/units/test_merge.rb104
2 files changed, 107 insertions, 1 deletions
diff --git a/tests/units/test_branch.rb b/tests/units/test_branch.rb
index 1560c55..bc7d807 100644
--- a/tests/units/test_branch.rb
+++ b/tests/units/test_branch.rb
@@ -68,7 +68,9 @@ class TestBranch < Test::Unit::TestCase
assert(g.status.untracked.assoc('test-file1'))
assert(!g.status.added.assoc('test-file1'))
- g.branch('new_branch').delete
+ assert_raise Git::GitExecuteError do
+ g.branch('new_branch').delete
+ end
assert_equal(1, g.branches.select { |b| b.name == 'new_branch' }.size)
g.branch('master').checkout
diff --git a/tests/units/test_merge.rb b/tests/units/test_merge.rb
new file mode 100644
index 0000000..a0d74c3
--- /dev/null
+++ b/tests/units/test_merge.rb
@@ -0,0 +1,104 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TestMerge < Test::Unit::TestCase
+ def setup
+ set_file_paths
+ end
+
+ def test_branch_and_merge
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'branch_merge_test')
+ Dir.chdir('branch_merge_test') do
+
+ g.branch('new_branch').in_branch('test') do
+ assert_equal('new_branch', g.current_branch)
+ new_file('new_file_1', 'hello')
+ new_file('new_file_2', 'hello')
+ g.add
+ true
+ end
+
+ assert_equal('master', g.current_branch)
+
+ new_file('new_file_3', 'hello')
+ g.add
+
+ assert(!g.status['new_file_1']) # file is not there
+
+ assert(g.branch('new_branch').merge)
+ assert(g.status['new_file_1']) # file has been merged in
+ end
+ end
+ end
+
+ def test_branch_and_merge_two
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'branch_merge_test')
+ Dir.chdir('branch_merge_test') do
+
+ g.branch('new_branch').in_branch('test') do
+ assert_equal('new_branch', g.current_branch)
+ new_file('new_file_1', 'hello')
+ new_file('new_file_2', 'hello')
+ g.add
+ true
+ end
+
+ g.branch('new_branch2').in_branch('test') do
+ assert_equal('new_branch2', g.current_branch)
+ new_file('new_file_3', 'hello')
+ new_file('new_file_4', 'hello')
+ g.add
+ true
+ end
+
+ g.branch('new_branch').merge('new_branch2')
+ assert(!g.status['new_file_3']) # still in master branch
+
+ g.branch('new_branch').checkout
+ assert(g.status['new_file_3']) # file has been merged in
+
+ g.branch('master').checkout
+ g.merge(g.branch('new_branch'))
+ assert(g.status['new_file_3']) # file has been merged in
+
+ end
+ end
+ end
+
+ def test_branch_and_merge_multiple
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'branch_merge_test')
+ Dir.chdir('branch_merge_test') do
+
+ g.branch('new_branch').in_branch('test') do
+ assert_equal('new_branch', g.current_branch)
+ new_file('new_file_1', 'hello')
+ new_file('new_file_2', 'hello')
+ g.add
+ true
+ end
+
+ g.branch('new_branch2').in_branch('test') do
+ assert_equal('new_branch2', g.current_branch)
+ new_file('new_file_3', 'hello')
+ new_file('new_file_4', 'hello')
+ g.add
+ true
+ end
+
+ assert(!g.status['new_file_1']) # still in master branch
+ assert(!g.status['new_file_3']) # still in master branch
+
+ g.merge(['new_branch', 'new_branch2'])
+
+ assert(g.status['new_file_1']) # file has been merged in
+ assert(g.status['new_file_3']) # file has been merged in
+
+ end
+ end
+ end
+
+end \ No newline at end of file