summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-27 08:21:48 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-27 08:21:48 -0800
commit779f21b307e7c119a56700fb14f88ba63a2cccc2 (patch)
treef3f03821dbe66f581ae2707e6e872395adc7afbe /tests
parent55c3c134c5c19103ed52fbd615d5af351fa9bb34 (diff)
parent6a9db968e8563bc27b8f56f9d413159a2e14cf67 (diff)
downloadthird_party-ruby-git-779f21b307e7c119a56700fb14f88ba63a2cccc2.tar.gz
third_party-ruby-git-779f21b307e7c119a56700fb14f88ba63a2cccc2.tar.xz
third_party-ruby-git-779f21b307e7c119a56700fb14f88ba63a2cccc2.zip
Merge branches 'master' and 'internals'
Diffstat (limited to 'tests')
-rw-r--r--tests/test_helper.rb10
-rw-r--r--tests/units/test_index_ops.rb2
-rw-r--r--tests/units/test_lib.rb9
-rw-r--r--tests/units/test_log.rb3
-rw-r--r--tests/units/test_raw_internals.rb53
5 files changed, 75 insertions, 2 deletions
diff --git a/tests/test_helper.rb b/tests/test_helper.rb
index 9907ffe..e40174a 100644
--- a/tests/test_helper.rb
+++ b/tests/test_helper.rb
@@ -28,6 +28,16 @@ class Test::Unit::TestCase
end
end
+
+ def with_temp_bare
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'new')
+ Dir.chdir('new') do
+ yield g
+ end
+ end
+ end
+
def create_temp_repo(clone_path)
filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s.rjust(3, '0')
@tmp_path = File.join("/tmp/", filename)
diff --git a/tests/units/test_index_ops.rb b/tests/units/test_index_ops.rb
index f92ae9e..dcd8498 100644
--- a/tests/units/test_index_ops.rb
+++ b/tests/units/test_index_ops.rb
@@ -10,7 +10,7 @@ class TestIndexOps < Test::Unit::TestCase
end
def test_add
- in_temp_dir(false) do |path|
+ in_temp_dir do |path|
g = Git.clone(@wbare, 'new')
Dir.chdir('new') do
assert_equal('100644', g.status['example.txt'].mode_index)
diff --git a/tests/units/test_lib.rb b/tests/units/test_lib.rb
index f9170e6..7cbbeef 100644
--- a/tests/units/test_lib.rb
+++ b/tests/units/test_lib.rb
@@ -102,6 +102,15 @@ class TestLib < Test::Unit::TestCase
assert_equal('+refs/heads/*:refs/remotes/working/*', config['fetch'])
end
+
+ def test_ls_tree
+ tree = @lib.ls_tree('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7')
+ assert_equal("3aac4b445017a8fc07502670ec2dbf744213dd48", tree['blob']['example.txt'][:sha])
+ assert_equal("100644", tree['blob']['example.txt'][:mode])
+ assert(tree['tree'])
+ end
+
+
# options this will accept
# :treeish
# :path_limiter
diff --git a/tests/units/test_log.rb b/tests/units/test_log.rb
index 11dcb27..7bcd83b 100644
--- a/tests/units/test_log.rb
+++ b/tests/units/test_log.rb
@@ -1,10 +1,11 @@
#!/usr/bin/env ruby
-
+require 'logger'
require File.dirname(__FILE__) + '/../test_helper'
class TestLog < Test::Unit::TestCase
def setup
set_file_paths
+ #@git = Git.open(@wdir, :log => Logger.new(STDOUT))
@git = Git.open(@wdir)
end
diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb
new file mode 100644
index 0000000..b37a66d
--- /dev/null
+++ b/tests/units/test_raw_internals.rb
@@ -0,0 +1,53 @@
+#!/usr/bin/env ruby
+require 'logger'
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TestRawInternals < Test::Unit::TestCase
+
+ def setup
+ set_file_paths
+ end
+
+ def test_raw_log
+ with_temp_bare do |g|
+ t_log(g)
+ end
+ end
+
+ def test_packed_log
+ with_temp_bare do |g|
+ g.repack
+ t_log(g)
+ end
+ end
+
+ def test_commit_object
+ g = Git.bare(@wbare)
+ c = g.gcommit("v2.5")
+ assert_equal('test', c.message)
+ end
+
+ def test_lstree
+ g = Git.bare(@wbare)
+ c = g.object("v2.5").gtree
+ sha = c.sha
+
+ repo = Git::Raw::Repository.new(@wbare)
+ assert_equal('ex_dir', repo.object(sha).entry.first.name)
+ end
+
+ def t_log(g)
+ c = g.object("v2.5")
+ sha = c.sha
+
+ repo = Git::Raw::Repository.new(g.repo.path)
+ raw_out = repo.log(sha)
+
+ assert_equal('commit 546bec6f8872efa41d5d97a369f669165ecda0de', raw_out.split("\n").first)
+ assert_equal('546bec6f8872efa41d5d97a369f669165ecda0de', c.log(30).first.sha)
+ end
+
+
+
+
+end \ No newline at end of file