summaryrefslogtreecommitdiffstats
path: root/tests/units
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/test_branch.rb42
-rw-r--r--tests/units/test_index_ops.rb12
2 files changed, 42 insertions, 12 deletions
diff --git a/tests/units/test_branch.rb b/tests/units/test_branch.rb
index c1fe9d6..1560c55 100644
--- a/tests/units/test_branch.rb
+++ b/tests/units/test_branch.rb
@@ -46,4 +46,46 @@ class TestBranch < Test::Unit::TestCase
assert_equal(270, @git.branches[:test_branches].gcommit.size)
end
+ def test_branch_create_and_switch
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'branch_test')
+ Dir.chdir('branch_test') do
+ assert(!g.branch('new_branch').current)
+ g.branch('other_branch').create
+ g.branch('new_branch').checkout
+ assert(g.branch('new_branch').current)
+
+ assert_equal(1, g.branches.select { |b| b.name == 'new_branch' }.size)
+
+ new_file('test-file1', 'blahblahblah1')
+ new_file('test-file2', 'blahblahblah2')
+ assert(g.status.untracked.assoc('test-file1'))
+
+ g.add(['test-file1', 'test-file2'])
+ assert(!g.status.untracked.assoc('test-file1'))
+
+ g.reset
+ assert(g.status.untracked.assoc('test-file1'))
+ assert(!g.status.added.assoc('test-file1'))
+
+ g.branch('new_branch').delete
+ assert_equal(1, g.branches.select { |b| b.name == 'new_branch' }.size)
+
+ g.branch('master').checkout
+ g.branch('new_branch').delete
+ assert_equal(0, g.branches.select { |b| b.name == 'new_branch' }.size)
+
+ g.checkout('other_branch')
+ assert(g.branch('other_branch').current)
+
+ g.checkout('master')
+ assert(!g.branch('other_branch').current)
+
+ g.checkout(g.branch('other_branch'))
+ assert(g.branch('other_branch').current)
+
+ end
+ end
+ end
+
end \ No newline at end of file
diff --git a/tests/units/test_index_ops.rb b/tests/units/test_index_ops.rb
index b3946b8..de3a9c3 100644
--- a/tests/units/test_index_ops.rb
+++ b/tests/units/test_index_ops.rb
@@ -91,16 +91,4 @@ class TestIndexOps < Test::Unit::TestCase
end
end
- def new_file(name, contents)
- File.open(name, 'w') do |f|
- f.puts contents
- end
- end
-
- def append_file(name, contents)
- File.open(name, 'a') do |f|
- f.puts contents
- end
- end
-
end \ No newline at end of file