##// END OF EJS Templates
scm: mercurial: fix assert_equal parameter order at app unit test_find_changeset_by_name()....
Toshi MARUYAMA -
r4535:7484096cdcaf
parent child
Show More
@@ -1,146 +1,146
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class RepositoryMercurialTest < ActiveSupport::TestCase
21 21 fixtures :projects
22 22
23 23 # No '..' in the repository path
24 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
25 25
26 26 def setup
27 27 @project = Project.find(1)
28 28 assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH)
29 29 end
30 30
31 31 if File.directory?(REPOSITORY_PATH)
32 32 def test_fetch_changesets_from_scratch
33 33 @repository.fetch_changesets
34 34 @repository.reload
35 35
36 36 assert_equal 17, @repository.changesets.count
37 37 assert_equal 25, @repository.changes.count
38 38 assert_equal "Initial import.\nThe repository contains 3 files.",
39 39 @repository.changesets.find_by_revision('0').comments
40 40 end
41 41
42 42 def test_fetch_changesets_incremental
43 43 @repository.fetch_changesets
44 44 # Remove changesets with revision > 2
45 45 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
46 46 @repository.reload
47 47 assert_equal 3, @repository.changesets.count
48 48
49 49 @repository.fetch_changesets
50 50 assert_equal 17, @repository.changesets.count
51 51 end
52 52
53 53 def test_entries
54 54 assert_equal 2, @repository.entries("sources", 2).size
55 55 assert_equal 2, @repository.entries("sources", '400bb8672109').size
56 56 assert_equal 1, @repository.entries("sources", 3).size
57 57 assert_equal 1, @repository.entries("sources", 'b3a615152df8').size
58 58 end
59 59
60 60 def test_locate_on_outdated_repository
61 61 assert_equal 1, @repository.entries("images", 0).size
62 62 assert_equal 2, @repository.entries("images").size
63 63 assert_equal 2, @repository.entries("images", 2).size
64 64 end
65 65
66 66 def test_isodatesec
67 67 # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher
68 68 if @repository.scm.class.client_version_above?([1, 0])
69 69 @repository.fetch_changesets
70 70 @repository.reload
71 71 rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52)
72 72 assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on
73 73 end
74 74 end
75 75
76 76 def test_changeset_order_by_revision
77 77 @repository.fetch_changesets
78 78 @repository.reload
79 79
80 80 c0 = @repository.latest_changeset
81 81 c1 = @repository.changesets.find_by_revision('0')
82 82 # sorted by revision (id), not by date
83 83 assert c0.revision.to_i > c1.revision.to_i
84 84 assert c0.committed_on < c1.committed_on
85 85 end
86 86
87 87 def test_latest_changesets
88 88 @repository.fetch_changesets
89 89 @repository.reload
90 90
91 91 # with_limit
92 92 changesets = @repository.latest_changesets('', nil, 2)
93 93 assert_equal @repository.latest_changesets('', nil)[0, 2], changesets
94 94
95 95 # with_filepath
96 96 changesets = @repository.latest_changesets('/sql_escape/percent%dir/percent%file1.txt', nil)
97 97 assert_equal %w|11 10 9|, changesets.collect(&:revision)
98 98
99 99 changesets = @repository.latest_changesets('/sql_escape/underscore_dir/understrike_file.txt', nil)
100 100 assert_equal %w|12 9|, changesets.collect(&:revision)
101 101 end
102 102
103 103 def test_copied_files
104 104 @repository.fetch_changesets
105 105 @repository.reload
106 106
107 107 cs1 = @repository.changesets.find_by_revision('13')
108 108 assert_not_nil cs1
109 109 c1 = cs1.changes
110 110 assert_equal 2, c1.size
111 111
112 112 assert_equal 'A', c1[0].action
113 113 assert_equal '/sql_escape/percent%dir/percentfile1.txt', c1[0].path
114 114 assert_equal '/sql_escape/percent%dir/percent%file1.txt', c1[0].from_path
115 115
116 116 assert_equal 'A', c1[1].action
117 117 assert_equal '/sql_escape/underscore_dir/understrike-file.txt', c1[1].path
118 118 assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path
119 119
120 120 cs2 = @repository.changesets.find_by_revision('15')
121 121 c2 = cs2.changes
122 122 assert_equal 1, c2.size
123 123
124 124 assert_equal 'A', c2[0].action
125 125 assert_equal '/README (1)[2]&,%.-3_4', c2[0].path
126 126 assert_equal '/README', c2[0].from_path
127 127 end
128 128
129 129 def test_find_changeset_by_name
130 130 @repository.fetch_changesets
131 131 @repository.reload
132 132 %w|2 400bb8672109 400|.each do |r|
133 assert_equal @repository.find_changeset_by_name(r).revision, '2'
133 assert_equal '2', @repository.find_changeset_by_name(r).revision
134 134 end
135 135 end
136 136
137 137 def test_find_changeset_by_invalid_name
138 138 @repository.fetch_changesets
139 139 @repository.reload
140 140 assert_nil @repository.find_changeset_by_name('100000')
141 141 end
142 142 else
143 143 puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!"
144 144 def test_fake; assert true end
145 145 end
146 146 end
General Comments 0
You need to be logged in to leave comments. Login now