summaryrefslogtreecommitdiffstats
path: root/tests/units/test_object.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-08 17:07:04 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-08 17:07:04 -0800
commit1f63953f05a4afe74f881d54f69f77da513939d5 (patch)
tree5fabd81a82d8aa3df0e9cdc10b0ed7f6ff141b8a /tests/units/test_object.rb
parentb18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b (diff)
downloadthird_party-ruby-git-1f63953f05a4afe74f881d54f69f77da513939d5.tar.gz
third_party-ruby-git-1f63953f05a4afe74f881d54f69f77da513939d5.tar.xz
third_party-ruby-git-1f63953f05a4afe74f881d54f69f77da513939d5.zip
moved the git objects into the object.rb file
Diffstat (limited to 'tests/units/test_object.rb')
-rw-r--r--tests/units/test_object.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/units/test_object.rb b/tests/units/test_object.rb
new file mode 100644
index 0000000..610a640
--- /dev/null
+++ b/tests/units/test_object.rb
@@ -0,0 +1,58 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TestInit < Test::Unit::TestCase
+ def setup
+ set_file_paths
+ @git = Git.open(@wdir)
+ end
+
+ def test_commit
+ o = @git.object('1cc8667014381')
+ assert(o.is_a?(Git::Object::Commit))
+
+ o = @git.object('HEAD')
+ assert(o.is_a?(Git::Object::Commit))
+ assert_equal('commit', o.type)
+
+ o = @git.object('test_object')
+ assert(o.is_a?(Git::Object::Commit))
+ assert_equal('commit', o.type)
+ end
+
+ def test_commit_contents
+ o = @git.object('1cc8667014381')
+ assert_equal('tree 94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', o.contents_array[0])
+ assert_equal('parent 546bec6f8872efa41d5d97a369f669165ecda0de', o.contents_array[1])
+ end
+
+ def test_tree
+ o = @git.object('1cc8667014381^{tree}')
+ assert(o.is_a?(Git::Object::Tree))
+
+ o = @git.object('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7')
+ assert(o.is_a?(Git::Object::Tree))
+ assert_equal('tree', o.type)
+ end
+
+ def test_tree_contents
+ o = @git.object('1cc8667014381^{tree}')
+ assert_equal('040000 tree 6b790ddc5eab30f18cabdd0513e8f8dac0d2d3ed ex_dir', o.contents_array.first)
+ end
+
+ def test_blob
+ o = @git.object('ba492c62b6')
+ assert(o.is_a?(Git::Object::Blob))
+
+ o = @git.object('v2.5:example.txt')
+ assert(o.is_a?(Git::Object::Blob))
+ assert_equal('blob', o.type)
+ end
+
+ def test_blob_contents
+ o = @git.object('v2.6:example.txt')
+ assert_equal('replace with new text', o.contents)
+ end
+
+end \ No newline at end of file