summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/files/working/example.txt64
-rw-r--r--tests/units/test_log.rb29
-rw-r--r--tests/units/test_object.rb58
3 files changed, 86 insertions, 65 deletions
diff --git a/tests/files/working/example.txt b/tests/files/working/example.txt
index 8a3fb74..1f09f2e 100644
--- a/tests/files/working/example.txt
+++ b/tests/files/working/example.txt
@@ -1,63 +1 @@
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
+replace with new text
diff --git a/tests/units/test_log.rb b/tests/units/test_log.rb
index 4dd6a2f..ddd4988 100644
--- a/tests/units/test_log.rb
+++ b/tests/units/test_log.rb
@@ -10,10 +10,10 @@ 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::Commit))
end
- def test_get_log_entries
+ def test_get_log_entries
assert_equal(30, @git.log.size)
assert_equal(50, @git.log(50).size)
assert_equal(10, @git.log(10).size)
@@ -23,4 +23,29 @@ class TestInit < Test::Unit::TestCase
assert_equal(@git.log.to_s.split("\n").first, @git.log.first.sha)
end
+ def test_get_log_since
+ l = @git.log.since("2 seconds ago")
+ assert_equal(0, l.size)
+
+ l = @git.log.since("2 years ago")
+ assert_equal(30, l.size)
+ end
+
+ def test_get_log_since_file
+ l = @git.log.file('example.txt')
+ assert_equal(30, l.size)
+
+ l = @git.log.between('v2.5').file('example.txt')
+ assert_equal(1, l.size)
+
+ l = @git.log.between('v2.5', 'test').file('example.txt')
+ assert_equal(1, l.size)
+ end
+
+ def test_log_file_noexist
+ assert_raise Git::GitExecuteError do
+ @git.log.file('no-exist.txt').size
+ end
+ end
+
end
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