To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 4e / 4e9dba91f9f1e14e761643510fc2e1252decf990.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (2.36 KB)

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