summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Siebert <siebertm85@googlemail.com>2008-05-09 17:22:31 +0200
committerScott Chacon <schacon@gmail.com>2008-05-12 17:30:13 -0700
commit7df710fdb2e9b6376b3201ac6dee9ea6524f6e5f (patch)
treefc170fe0e81f1ca4e3ca3056544429b30de28af9 /tests
parentae106e2a3569e5ea874852c613ed060d8e232109 (diff)
downloadthird_party-ruby-git-7df710fdb2e9b6376b3201ac6dee9ea6524f6e5f.zip
third_party-ruby-git-7df710fdb2e9b6376b3201ac6dee9ea6524f6e5f.tar.gz
third_party-ruby-git-7df710fdb2e9b6376b3201ac6dee9ea6524f6e5f.tar.xz
Add the possibility to read blob contents in chunks via IO#popen
Diffstat (limited to 'tests')
-rw-r--r--tests/units/test_lib.rb27
-rw-r--r--tests/units/test_object.rb9
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/units/test_lib.rb b/tests/units/test_lib.rb
index 7cbbeef..59301f3 100644
--- a/tests/units/test_lib.rb
+++ b/tests/units/test_lib.rb
@@ -85,6 +85,33 @@ class TestLib < Test::Unit::TestCase
assert_equal(blob, @lib.object_contents('v2.5:example.txt')) #blob
end
+
+ def test_object_contents_with_block
+ commit = "tree 94c827875e2cadb8bc8d4cdd900f19aa9e8634c7\n"
+ commit += "parent 546bec6f8872efa41d5d97a369f669165ecda0de\n"
+ commit += "author scott Chacon <schacon@agadorsparticus.corp.reactrix.com> 1194561188 -0800\n"
+ commit += "committer scott Chacon <schacon@agadorsparticus.corp.reactrix.com> 1194561188 -0800\n"
+ commit += "\ntest"
+
+ @lib.object_contents('1cc8667014381') do |f|
+ assert_equal(commit, f.read.chomp)
+ end
+
+ # commit
+
+ tree = "040000 tree 6b790ddc5eab30f18cabdd0513e8f8dac0d2d3ed\tex_dir\n"
+ tree += "100644 blob 3aac4b445017a8fc07502670ec2dbf744213dd48\texample.txt"
+
+ @lib.object_contents('1cc8667014381^{tree}') do |f|
+ assert_equal(tree, f.read.chomp) #tree
+ end
+
+ blob = "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2"
+
+ @lib.object_contents('v2.5:example.txt') do |f|
+ assert_equal(blob, f.read.chomp) #blob
+ end
+ end
# returns Git::Branch object array
def test_branches_all
diff --git a/tests/units/test_object.rb b/tests/units/test_object.rb
index 543f021..427992b 100644
--- a/tests/units/test_object.rb
+++ b/tests/units/test_object.rb
@@ -102,6 +102,15 @@ class TestObject < Test::Unit::TestCase
o = @git.gblob('v2.6:example.txt')
assert_equal('replace with new text', o.contents)
assert_equal('replace with new text', o.contents) # this should be cached
+
+ # make sure the block is called
+ block_called = false
+ o.contents do |f|
+ block_called = true
+ assert_equal('replace with new text', f.read.chomp)
+ end
+
+ assert(block_called)
end
def test_revparse