Chris@1115: # Redmine - project management software Chris@1115: # Copyright (C) 2006-2012 Jean-Philippe Lang Chris@1115: # Chris@1115: # This program is free software; you can redistribute it and/or Chris@1115: # modify it under the terms of the GNU General Public License Chris@1115: # as published by the Free Software Foundation; either version 2 Chris@1115: # of the License, or (at your option) any later version. Chris@1115: # Chris@1115: # This program is distributed in the hope that it will be useful, Chris@1115: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1115: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1115: # GNU General Public License for more details. Chris@1115: # Chris@1115: # You should have received a copy of the GNU General Public License Chris@1115: # along with this program; if not, write to the Free Software Chris@1115: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@1115: Chris@210: require File.expand_path('../../../../../../test_helper', __FILE__) Chris@210: begin Chris@210: require 'mocha' Chris@441: Chris@210: class DarcsAdapterTest < ActiveSupport::TestCase Chris@909: REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s Chris@210: Chris@210: if File.directory?(REPOSITORY_PATH) Chris@210: def setup Chris@210: @adapter = Redmine::Scm::Adapters::DarcsAdapter.new(REPOSITORY_PATH) Chris@210: end Chris@210: Chris@210: def test_darcsversion Chris@210: to_test = { "1.0.9 (release)\n" => [1,0,9] , Chris@210: "2.2.0 (release)\n" => [2,2,0] } Chris@210: to_test.each do |s, v| Chris@210: test_darcsversion_for(s, v) Chris@210: end Chris@210: end Chris@210: Chris@210: def test_revisions Chris@210: id1 = '20080308225258-98289-761f654d669045eabee90b91b53a21ce5593cadf.gz' Chris@210: revs = @adapter.revisions('', nil, nil, {:with_path => true}) Chris@210: assert_equal 6, revs.size Chris@210: assert_equal id1, revs[5].scmid Chris@210: paths = revs[5].paths Chris@210: assert_equal 5, paths.size Chris@210: assert_equal 'A', paths[0][:action] Chris@210: assert_equal '/README', paths[0][:path] Chris@210: assert_equal 'A', paths[1][:action] Chris@210: assert_equal '/images', paths[1][:path] Chris@210: end Chris@210: Chris@210: private Chris@210: Chris@210: def test_darcsversion_for(darcsversion, version) Chris@210: @adapter.class.expects(:darcs_binary_version_from_command_line).returns(darcsversion) Chris@210: assert_equal version, @adapter.class.darcs_binary_version Chris@210: end Chris@210: Chris@210: else Chris@210: puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" Chris@210: def test_fake; assert true end Chris@210: end Chris@210: end Chris@210: Chris@210: rescue LoadError Chris@210: class DarcsMochaFake < ActiveSupport::TestCase Chris@210: def test_fake; assert(false, "Requires mocha to run those tests") end Chris@210: end Chris@210: end Chris@210: