summaryrefslogtreecommitdiffstats
path: root/tests/units/test_log.rb
blob: ddd498852a4a84f18863f65b7dc6d1fa2739955a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/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_get_log_entries
    log = @git.log
    assert(log.first.is_a?(Git::Commit))
  end
  
  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)
  end

  def test_get_log_to_s
    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