##// END OF EJS Templates
scm: fix assert_equal parameter order in subversion and git unit test....
Toshi MARUYAMA -
r4571:e92cd2091cbb
parent child
Show More
@@ -1,92 +1,93
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 RepositoryGitTest < ActiveSupport::TestCase
21 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22 22
23 23 # No '..' in the repository path
24 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
25 25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 26
27 27 def setup
28 28 @project = Project.find(1)
29 29 assert @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH)
30 30 end
31 31
32 32 if File.directory?(REPOSITORY_PATH)
33 33 def test_fetch_changesets_from_scratch
34 34 @repository.fetch_changesets
35 35 @repository.reload
36 36
37 37 assert_equal 15, @repository.changesets.count
38 38 assert_equal 24, @repository.changes.count
39 39
40 40 commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
41 41 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
42 42 assert_equal "jsmith <jsmith@foo.bar>", commit.committer
43 43 assert_equal User.find_by_login('jsmith'), commit.user
44 44 # TODO: add a commit with commit time <> author time to the test repository
45 45 assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
46 46 assert_equal "2007-12-14".to_date, commit.commit_date
47 47 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision
48 48 assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid
49 49 assert_equal 3, commit.changes.count
50 50 change = commit.changes.sort_by(&:path).first
51 51 assert_equal "README", change.path
52 52 assert_equal "A", change.action
53 53 end
54 54
55 55 def test_fetch_changesets_incremental
56 56 @repository.fetch_changesets
57 57 # Remove the 3 latest changesets
58 58 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
59 59 @repository.reload
60 60 assert_equal 12, @repository.changesets.count
61 61
62 62 @repository.fetch_changesets
63 63 assert_equal 15, @repository.changesets.count
64 64 end
65 65
66 66 def test_identifier
67 67 @repository.fetch_changesets
68 68 @repository.reload
69 69 c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518')
70 70 assert_equal c.scmid, c.identifier
71 71 end
72 72
73 73 def test_format_identifier
74 74 @repository.fetch_changesets
75 75 @repository.reload
76 76 c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518')
77 assert_equal c.format_identifier, '7234cb27'
77 assert_equal '7234cb27', c.format_identifier
78 78 end
79 79
80 80 def test_activities
81 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
81 c = Changeset.new(:repository => @repository,
82 :committed_on => Time.now,
82 83 :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
83 84 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2',
84 85 :comments => 'test')
85 86 assert c.event_title.include?('abc7234c:')
86 assert_equal c.event_url[:rev], 'abc7234cb2750b63f47bff735edc50a1c0a433c2'
87 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev]
87 88 end
88 89 else
89 90 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
90 91 def test_fake; assert true end
91 92 end
92 93 end
@@ -1,135 +1,135
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 RepositorySubversionTest < ActiveSupport::TestCase
21 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22 22
23 23 def setup
24 24 @project = Project.find(1)
25 25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}")
26 26 end
27 27
28 28 if repository_configured?('subversion')
29 29 def test_fetch_changesets_from_scratch
30 30 @repository.fetch_changesets
31 31 @repository.reload
32 32
33 33 assert_equal 11, @repository.changesets.count
34 34 assert_equal 20, @repository.changes.count
35 35 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
36 36 end
37 37
38 38 def test_fetch_changesets_incremental
39 39 @repository.fetch_changesets
40 40 # Remove changesets with revision > 5
41 41 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
42 42 @repository.reload
43 43 assert_equal 5, @repository.changesets.count
44 44
45 45 @repository.fetch_changesets
46 46 assert_equal 11, @repository.changesets.count
47 47 end
48 48
49 49 def test_latest_changesets
50 50 @repository.fetch_changesets
51 51
52 52 # with limit
53 53 changesets = @repository.latest_changesets('', nil, 2)
54 54 assert_equal 2, changesets.size
55 55 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets
56 56
57 57 # with path
58 58 changesets = @repository.latest_changesets('subversion_test/folder', nil)
59 59 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
60 60
61 61 # with path and revision
62 62 changesets = @repository.latest_changesets('subversion_test/folder', 8)
63 63 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
64 64 end
65 65
66 66 def test_directory_listing_with_square_brackets_in_path
67 67 @repository.fetch_changesets
68 68 @repository.reload
69 69
70 70 entries = @repository.entries('subversion_test/[folder_with_brackets]')
71 71 assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
72 72 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
73 73 assert_equal 'README.txt', entries.first.name
74 74 end
75 75
76 76 def test_directory_listing_with_square_brackets_in_base
77 77 @project = Project.find(1)
78 78 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
79 79
80 80 @repository.fetch_changesets
81 81 @repository.reload
82 82
83 83 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
84 84 assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add'
85 85
86 86 entries = @repository.entries('')
87 87 assert_not_nil entries, 'Expect to find entries'
88 88 assert_equal 1, entries.size, 'Expect a single entry'
89 89 assert_equal 'README.txt', entries.first.name
90 90 end
91 91
92 92 def test_identifier
93 93 @repository.fetch_changesets
94 94 @repository.reload
95 95 c = @repository.changesets.find_by_revision('1')
96 96 assert_equal c.revision, c.identifier
97 97 end
98 98
99 99 def test_identifier_nine_digit
100 100 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
101 101 :revision => '123456789', :comments => 'test')
102 102 assert_equal c.identifier, c.revision
103 103 end
104 104
105 105 def test_format_identifier
106 106 @repository.fetch_changesets
107 107 @repository.reload
108 108 c = @repository.changesets.find_by_revision('1')
109 109 assert_equal c.format_identifier, c.revision
110 110 end
111 111
112 112 def test_format_identifier_nine_digit
113 113 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
114 114 :revision => '123456789', :comments => 'test')
115 115 assert_equal c.format_identifier, c.revision
116 116 end
117 117
118 118 def test_activities
119 119 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
120 120 :revision => '1', :comments => 'test')
121 121 assert c.event_title.include?('1:')
122 assert_equal c.event_url[:rev], '1'
122 assert_equal '1', c.event_url[:rev]
123 123 end
124 124
125 125 def test_activities_nine_digit
126 126 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
127 127 :revision => '123456789', :comments => 'test')
128 128 assert c.event_title.include?('123456789:')
129 assert_equal c.event_url[:rev], '123456789'
129 assert_equal '123456789', c.event_url[:rev]
130 130 end
131 131 else
132 132 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
133 133 def test_fake; assert true end
134 134 end
135 135 end
General Comments 0
You need to be logged in to leave comments. Login now