annotate test/unit/lib/redmine/scm/adapters/git_adapter_test.rb @ 36:de76cd3e8c8e cc-branches

* Probably abortive experiments in extracting the branch from Hg
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 20 Oct 2010 10:07:29 +0100
parents 1d32c0a0efbf
children 94944d00e43c
rev   line source
Chris@0 1 require File.dirname(__FILE__) + '/../../../../../test_helper'
Chris@0 2
Chris@0 3 class GitAdapterTest < ActiveSupport::TestCase
Chris@0 4 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
Chris@0 5
Chris@0 6 if File.directory?(REPOSITORY_PATH)
Chris@0 7 def setup
Chris@0 8 @adapter = Redmine::Scm::Adapters::GitAdapter.new(REPOSITORY_PATH)
Chris@0 9 end
Chris@0 10
Chris@0 11 def test_branches
Chris@0 12 assert_equal @adapter.branches, ['master', 'test_branch']
Chris@0 13 end
Chris@0 14
Chris@0 15 def test_getting_all_revisions
Chris@0 16 assert_equal 13, @adapter.revisions('',nil,nil,:all => true).length
Chris@0 17 end
Chris@0 18
Chris@14 19 def test_getting_certain_revisions
Chris@14 20 assert_equal 1, @adapter.revisions('','899a15d^','899a15d').length
Chris@14 21 end
Chris@14 22
Chris@0 23 def test_annotate
Chris@0 24 annotate = @adapter.annotate('sources/watchers_controller.rb')
Chris@0 25 assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
Chris@0 26 assert_equal 41, annotate.lines.size
Chris@0 27 assert_equal "# This program is free software; you can redistribute it and/or", annotate.lines[4].strip
Chris@0 28 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", annotate.revisions[4].identifier
Chris@0 29 assert_equal "jsmith", annotate.revisions[4].author
Chris@0 30 end
Chris@0 31
Chris@0 32 def test_annotate_moved_file
Chris@0 33 annotate = @adapter.annotate('renamed_test.txt')
Chris@0 34 assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
Chris@0 35 assert_equal 2, annotate.lines.size
Chris@0 36 end
Chris@0 37 else
Chris@0 38 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
Chris@0 39 def test_fake; assert true end
Chris@0 40 end
Chris@0 41 end