diff options
author | scott Chacon <schacon@agadorsparticus.corp.reactrix.com> | 2007-11-08 17:25:41 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.corp.reactrix.com> | 2007-11-08 17:25:41 -0800 |
commit | 10045d082117d4ef35da31e1c5a825507b02dd97 (patch) | |
tree | b418c5d28334e8514a075effc20c1ebdcbf34a25 /tests | |
parent | 1f63953f05a4afe74f881d54f69f77da513939d5 (diff) | |
download | third_party-ruby-git-10045d082117d4ef35da31e1c5a825507b02dd97.tar.gz third_party-ruby-git-10045d082117d4ef35da31e1c5a825507b02dd97.tar.xz third_party-ruby-git-10045d082117d4ef35da31e1c5a825507b02dd97.zip |
got all the unit tests to run from either place, fixed some old functionality
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_helper.rb | 15 | ||||
-rw-r--r-- | tests/units/test_log.rb | 6 | ||||
-rw-r--r-- | tests/units/test_object.rb | 13 |
3 files changed, 27 insertions, 7 deletions
diff --git a/tests/test_helper.rb b/tests/test_helper.rb index 4a1cac9..fe8c34d 100644 --- a/tests/test_helper.rb +++ b/tests/test_helper.rb @@ -5,9 +5,18 @@ require File.dirname(__FILE__) + '/../lib/git' class Test::Unit::TestCase def set_file_paths - @wdir = File.join(File.dirname(__FILE__), 'files', 'working') - @wbare = File.join(File.dirname(__FILE__), 'files', 'working.git') - @index = File.join(File.dirname(__FILE__), 'files', 'index') + cwd = `pwd`.chomp + if File.directory?(File.join(cwd, 'files')) + @test_dir = File.join(cwd, 'files') + elsif File.directory?(File.join(cwd, '..', 'files')) + @test_dir = File.join(cwd, '..', 'files') + elsif File.directory?(File.join(cwd, 'tests', 'files')) + @test_dir = File.join(cwd, 'tests', 'files') + end + + @wdir = File.join(@test_dir, 'working') + @wbare = File.join(@test_dir, 'working.git') + @index = File.join(@test_dir, 'index') end def in_temp_dir diff --git a/tests/units/test_log.rb b/tests/units/test_log.rb index ddd4988..770c245 100644 --- a/tests/units/test_log.rb +++ b/tests/units/test_log.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../test_helper' -class TestInit < Test::Unit::TestCase +class TestLog < Test::Unit::TestCase def setup set_file_paths @git = Git.open(@wdir) @@ -10,7 +10,7 @@ class TestInit < Test::Unit::TestCase def test_get_log_entries log = @git.log - assert(log.first.is_a?(Git::Commit)) + assert(log.first.is_a?(Git::Object::Commit)) end def test_get_log_entries @@ -36,7 +36,7 @@ class TestInit < Test::Unit::TestCase assert_equal(30, l.size) l = @git.log.between('v2.5').file('example.txt') - assert_equal(1, l.size) + assert_equal(2, l.size) l = @git.log.between('v2.5', 'test').file('example.txt') assert_equal(1, l.size) diff --git a/tests/units/test_object.rb b/tests/units/test_object.rb index 610a640..b535be7 100644 --- a/tests/units/test_object.rb +++ b/tests/units/test_object.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../test_helper' -class TestInit < Test::Unit::TestCase +class TestObject < Test::Unit::TestCase def setup set_file_paths @git = Git.open(@wdir) @@ -27,6 +27,17 @@ class TestInit < Test::Unit::TestCase assert_equal('parent 546bec6f8872efa41d5d97a369f669165ecda0de', o.contents_array[1]) end + def test_object_to_s + o = @git.object('1cc8667014381') + assert_equal('commit 1cc8667014381e2788a94777532a788307f38d26', o.to_s) + + o = @git.object('1cc8667014381^{tree}') + assert_equal('tree 94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', o.to_s) + + o = @git.object('v2.5:example.txt') + assert_equal('blob ba492c62b6227d7f3507b4dcc6e6d5f13790eabf', o.to_s) + end + def test_tree o = @git.object('1cc8667014381^{tree}') assert(o.is_a?(Git::Object::Tree)) |