annotate test/unit/lib/redmine/scm/adapters/darcs_adapter_test.rb @ 1466:834828a14f2b bug_598

Close obsolete branch bug_598
author Chris Cannam
date Fri, 21 Jun 2013 14:51:55 +0100
parents 433d4f72a19b
children 622f24f53b42 261b3d9a4903
rev   line source
Chris@1115 1 # Redmine - project management software
Chris@1115 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@1115 3 #
Chris@1115 4 # This program is free software; you can redistribute it and/or
Chris@1115 5 # modify it under the terms of the GNU General Public License
Chris@1115 6 # as published by the Free Software Foundation; either version 2
Chris@1115 7 # of the License, or (at your option) any later version.
Chris@1115 8 #
Chris@1115 9 # This program is distributed in the hope that it will be useful,
Chris@1115 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1115 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1115 12 # GNU General Public License for more details.
Chris@1115 13 #
Chris@1115 14 # You should have received a copy of the GNU General Public License
Chris@1115 15 # along with this program; if not, write to the Free Software
Chris@1115 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1115 17
Chris@210 18 require File.expand_path('../../../../../../test_helper', __FILE__)
Chris@210 19 begin
Chris@210 20 require 'mocha'
Chris@441 21
Chris@210 22 class DarcsAdapterTest < ActiveSupport::TestCase
Chris@909 23 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
Chris@210 24
Chris@210 25 if File.directory?(REPOSITORY_PATH)
Chris@210 26 def setup
Chris@210 27 @adapter = Redmine::Scm::Adapters::DarcsAdapter.new(REPOSITORY_PATH)
Chris@210 28 end
Chris@210 29
Chris@210 30 def test_darcsversion
Chris@210 31 to_test = { "1.0.9 (release)\n" => [1,0,9] ,
Chris@210 32 "2.2.0 (release)\n" => [2,2,0] }
Chris@210 33 to_test.each do |s, v|
Chris@210 34 test_darcsversion_for(s, v)
Chris@210 35 end
Chris@210 36 end
Chris@210 37
Chris@210 38 def test_revisions
Chris@210 39 id1 = '20080308225258-98289-761f654d669045eabee90b91b53a21ce5593cadf.gz'
Chris@210 40 revs = @adapter.revisions('', nil, nil, {:with_path => true})
Chris@210 41 assert_equal 6, revs.size
Chris@210 42 assert_equal id1, revs[5].scmid
Chris@210 43 paths = revs[5].paths
Chris@210 44 assert_equal 5, paths.size
Chris@210 45 assert_equal 'A', paths[0][:action]
Chris@210 46 assert_equal '/README', paths[0][:path]
Chris@210 47 assert_equal 'A', paths[1][:action]
Chris@210 48 assert_equal '/images', paths[1][:path]
Chris@210 49 end
Chris@210 50
Chris@210 51 private
Chris@210 52
Chris@210 53 def test_darcsversion_for(darcsversion, version)
Chris@210 54 @adapter.class.expects(:darcs_binary_version_from_command_line).returns(darcsversion)
Chris@210 55 assert_equal version, @adapter.class.darcs_binary_version
Chris@210 56 end
Chris@210 57
Chris@210 58 else
Chris@210 59 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
Chris@210 60 def test_fake; assert true end
Chris@210 61 end
Chris@210 62 end
Chris@210 63
Chris@210 64 rescue LoadError
Chris@210 65 class DarcsMochaFake < ActiveSupport::TestCase
Chris@210 66 def test_fake; assert(false, "Requires mocha to run those tests") end
Chris@210 67 end
Chris@210 68 end
Chris@210 69