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