summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 10:43:27 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 10:43:27 -0800
commita4fa110279ea28873fe1e4df10c89ddc591046b4 (patch)
tree60e08ccf8caca2fe428dee76c06c102cc54bc98b /tests
parenta1237671ba3ec38f5b123ee6600e4352dc03196b (diff)
downloadthird_party-ruby-git-a4fa110279ea28873fe1e4df10c89ddc591046b4.zip
third_party-ruby-git-a4fa110279ea28873fe1e4df10c89ddc591046b4.tar.gz
third_party-ruby-git-a4fa110279ea28873fe1e4df10c89ddc591046b4.tar.xz
added the commit(), changed base.commit, base.tree, base.blob to gcommit, gtree, gblob
Diffstat (limited to 'tests')
-rw-r--r--tests/all_tests.rb1
-rw-r--r--tests/units/test_diff.rb6
-rw-r--r--tests/units/test_index.rb35
-rw-r--r--tests/units/test_object.rb8
4 files changed, 40 insertions, 10 deletions
diff --git a/tests/all_tests.rb b/tests/all_tests.rb
index 0fc5f75..d671b24 100644
--- a/tests/all_tests.rb
+++ b/tests/all_tests.rb
@@ -1,3 +1,4 @@
Dir.chdir(File.dirname(__FILE__)) do
Dir.glob('**/test_*.rb') { |test_case| require test_case }
+ #Dir.glob('**/test_index.rb') { |test_case| require test_case }
end
diff --git a/tests/units/test_diff.rb b/tests/units/test_diff.rb
index b989c8a..16db0f3 100644
--- a/tests/units/test_diff.rb
+++ b/tests/units/test_diff.rb
@@ -31,18 +31,18 @@ class TestDiff < Test::Unit::TestCase
end
def test_diff_objects
- d = @git.diff('gitsearch1', @git.tree('v2.5'))
+ d = @git.diff('gitsearch1', @git.gtree('v2.5'))
assert(3, d.size)
end
def test_object_diff
- d = @git.tree('v2.5').diff('gitsearch1')
+ d = @git.gtree('v2.5').diff('gitsearch1')
assert_equal(3, d.size)
assert_equal(74, d.lines)
assert_equal(10, d.insertions)
assert_equal(64, d.deletions)
- d = @git.tree('v2.6').diff(@git.tree('gitsearch1'))
+ d = @git.gtree('v2.6').diff(@git.gtree('gitsearch1'))
assert_equal(2, d.size)
assert_equal(9, d.lines)
end
diff --git a/tests/units/test_index.rb b/tests/units/test_index.rb
index cf20eaf..b4e2f81 100644
--- a/tests/units/test_index.rb
+++ b/tests/units/test_index.rb
@@ -11,24 +11,53 @@ class TestIndex< Test::Unit::TestCase
def test_add
in_temp_dir do |path|
- #puts path
g = Git.clone(@wbare, 'new')
Dir.chdir('new') do
- assert_equal('100644', g.status['example.txt'].mode_index)
+ puts `pwd`
+ #assert_equal('100644', g.status['example.txt'].mode_index)
+
new_file('test-file', 'blahblahblah')
assert(g.status.untracked.assoc('test-file'))
+
g.add
assert(g.status.added.assoc('test-file'))
assert(!g.status.untracked.assoc('test-file'))
assert(!g.status.changed.assoc('example.txt'))
+
append_file('example.txt', 'hahahaha')
+ puts g.status.pretty
assert(g.status.changed.assoc('example.txt'))
+
g.add
assert(g.status.changed.assoc('example.txt'))
+
g.commit('my message')
assert(!g.status.changed.assoc('example.txt'))
assert(!g.status.added.assoc('test-file'))
- assert(!g.status.untracked.assoc('test-file'))
+ assert(!g.status.untracked.assoc('test-file'))
+ assert_equal('hahahaha', g.status['example.txt'].blob.contents)
+ end
+ end
+ end
+
+ def test_add_array
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'new')
+ Dir.chdir('new') do
+
+ 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.added.assoc('test-file1'))
+ assert(g.status.added.assoc('test-file1'))
+ assert(!g.status.untracked.assoc('test-file1'))
+
+ g.commit('my message')
+ assert(!g.status.added.assoc('test-file1'))
+ assert(!g.status.untracked.assoc('test-file1'))
+ assert_equal('blahblahblah1', g.status['test-file1'].blob.contents)
end
end
end
diff --git a/tests/units/test_object.rb b/tests/units/test_object.rb
index c115b75..a8c6bce 100644
--- a/tests/units/test_object.rb
+++ b/tests/units/test_object.rb
@@ -77,17 +77,17 @@ class TestObject < Test::Unit::TestCase
end
def test_grep
- g = @git.tree('a3db7143944dcfa0').grep('search') # there
+ g = @git.gtree('a3db7143944dcfa0').grep('search') # there
assert_equal(3, g.to_a.flatten.size)
assert_equal(1, g.size)
- assert_equal({}, @git.tree('a3db7143944dcfa0').grep('34a566d193')) # not there
+ assert_equal({}, @git.gtree('a3db7143944dcfa0').grep('34a566d193')) # not there
- g = @git.commit('gitsearch1').grep('search') # there
+ g = @git.gcommit('gitsearch1').grep('search') # there
assert_equal(8, g.to_a.flatten.size)
assert_equal(2, g.size)
- g = @git.commit('gitsearch1').grep('search', 'scott/new*') # there
+ g = @git.gcommit('gitsearch1').grep('search', 'scott/new*') # there
assert_equal(3, g.to_a.flatten.size)
assert_equal(1, g.size)
end