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