Chris@441: # Redmine - project management software Chris@1494: # Copyright (C) 2006-2014 Jean-Philippe Lang Chris@0: # Chris@0: # This program is free software; you can redistribute it and/or Chris@0: # modify it under the terms of the GNU General Public License Chris@0: # as published by the Free Software Foundation; either version 2 Chris@0: # of the License, or (at your option) any later version. Chris@441: # Chris@0: # This program is distributed in the hope that it will be useful, Chris@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: # GNU General Public License for more details. Chris@441: # Chris@0: # You should have received a copy of the GNU General Public License Chris@0: # along with this program; if not, write to the Free Software Chris@0: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@0: Chris@119: require File.expand_path('../../../../../../test_helper', __FILE__) Chris@0: Chris@245: begin Chris@1464: require 'mocha/setup' Chris@245: Chris@245: class SubversionAdapterTest < ActiveSupport::TestCase Chris@441: Chris@245: if repository_configured?('subversion') Chris@245: def setup Chris@441: @adapter = Redmine::Scm::Adapters::SubversionAdapter.new(self.class.subversion_repository_url) Chris@245: end Chris@245: Chris@245: def test_client_version Chris@245: v = Redmine::Scm::Adapters::SubversionAdapter.client_version Chris@245: assert v.is_a?(Array) Chris@245: end Chris@245: Chris@245: def test_scm_version Chris@245: to_test = { "svn, version 1.6.13 (r1002816)\n" => [1,6,13], Chris@245: "svn, versione 1.6.13 (r1002816)\n" => [1,6,13], Chris@245: "1.6.1\n1.7\n1.8" => [1,6,1], Chris@245: "1.6.2\r\n1.8.1\r\n1.9.1" => [1,6,2]} Chris@245: to_test.each do |s, v| Chris@245: test_scm_version_for(s, v) Chris@245: end Chris@245: end Chris@245: Chris@909: def test_info_not_nil Chris@909: assert_not_nil @adapter.info Chris@909: end Chris@909: Chris@909: def test_info_nil Chris@909: adpt = Redmine::Scm::Adapters::SubversionAdapter.new( Chris@909: "file:///invalid/invalid/" Chris@909: ) Chris@909: assert_nil adpt.info Chris@909: end Chris@909: Chris@245: private Chris@245: Chris@245: def test_scm_version_for(scm_version, version) Chris@245: @adapter.class.expects(:scm_version_from_command_line).returns(scm_version) Chris@245: assert_equal version, @adapter.class.svn_binary_version Chris@245: end Chris@245: else Chris@245: puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" Chris@245: def test_fake; assert true end Chris@0: end Chris@245: end Chris@245: rescue LoadError Chris@245: class SubversionMochaFake < ActiveSupport::TestCase Chris@245: def test_fake; assert(false, "Requires mocha to run those tests") end Chris@0: end Chris@0: end