diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-11 12:21:30 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-11 12:21:30 -0800 |
commit | abcb1453e210beb6de70a69d3501cf842b38636e (patch) | |
tree | 0612905ab3ec279694d2780b43274cb332757d1a /tests/units/test_branch.rb | |
parent | 3cb57d82c301e9b8a16f30f468401e3007845bb7 (diff) | |
download | third_party-ruby-git-abcb1453e210beb6de70a69d3501cf842b38636e.tar.gz third_party-ruby-git-abcb1453e210beb6de70a69d3501cf842b38636e.tar.xz third_party-ruby-git-abcb1453e210beb6de70a69d3501cf842b38636e.zip |
added branch and checkout functionality
Diffstat (limited to 'tests/units/test_branch.rb')
-rw-r--r-- | tests/units/test_branch.rb | 42 |
1 files changed, 42 insertions, 0 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 |