Sha256: b0f28575afe6ea8e1e0e86d4b7279d9fc1fddda056c242be1ef6e38849760b94

Contents?: true

Size: 1.57 KB

Versions: 25

Compression:

Stored size: 1.57 KB

Contents

#!/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

  def test_get_log_entries
    log = @git.log
    assert(log.first.is_a?(Git::Object::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_log_skip
    three1 = @git.log(3).to_a[-1]
    three2 = @git.log(2).skip(1).to_a[-1]
    three3 = @git.log(1).skip(2).to_a[-1]
    assert_equal(three2.sha, three3.sha)
    assert_equal(three1.sha, three2.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_grep
    l = @git.log.grep("search")
    assert_equal(2, l.size)
  end

  def test_get_log_author
    l = @git.log(5).author("chacon")
    assert_equal(5, l.size)
    l = @git.log(5).author("lazySusan")
    assert_equal(0, l.size)
  end
  
  def test_get_log_since_file    
    l = @git.log.object('example.txt')
    assert_equal(30, l.size)
  
    l = @git.log.between('v2.5', 'test').path('example.txt')
    assert_equal(1, l.size)
  end
  
  def test_log_file_noexist
    assert_raise Git::GitExecuteError do
      @git.log.object('no-exist.txt').size
    end
  end
  
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
titanous-git-1.1.0 tests/units/test_log.rb
redcar-dev-0.12.1dev-java plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-dev-0.12.0dev-java plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.11 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.11.0dev plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.10 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.9.2 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.9.1 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.9.0 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.8.1 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.8 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.7 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.6.1 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.6 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.6.1dev plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.5.1 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.5 plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.5.6dev plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.5.5dev plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb
redcar-0.5.4dev plugins/scm_git/vendor/ruby-git/tests/units/test_log.rb