Mercurial > hg > soundsoftware-site
comparison test/unit/repository_subversion_test.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # redMine - project management software | |
2 # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper' | |
19 | |
20 class RepositorySubversionTest < ActiveSupport::TestCase | |
21 fixtures :projects, :repositories | |
22 | |
23 def setup | |
24 @project = Project.find(1) | |
25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}") | |
26 end | |
27 | |
28 if repository_configured?('subversion') | |
29 def test_fetch_changesets_from_scratch | |
30 @repository.fetch_changesets | |
31 @repository.reload | |
32 | |
33 assert_equal 11, @repository.changesets.count | |
34 assert_equal 20, @repository.changes.count | |
35 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments | |
36 end | |
37 | |
38 def test_fetch_changesets_incremental | |
39 @repository.fetch_changesets | |
40 # Remove changesets with revision > 5 | |
41 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5} | |
42 @repository.reload | |
43 assert_equal 5, @repository.changesets.count | |
44 | |
45 @repository.fetch_changesets | |
46 assert_equal 11, @repository.changesets.count | |
47 end | |
48 | |
49 def test_latest_changesets | |
50 @repository.fetch_changesets | |
51 | |
52 # with limit | |
53 changesets = @repository.latest_changesets('', nil, 2) | |
54 assert_equal 2, changesets.size | |
55 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets | |
56 | |
57 # with path | |
58 changesets = @repository.latest_changesets('subversion_test/folder', nil) | |
59 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision) | |
60 | |
61 # with path and revision | |
62 changesets = @repository.latest_changesets('subversion_test/folder', 8) | |
63 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision) | |
64 end | |
65 | |
66 def test_directory_listing_with_square_brackets_in_path | |
67 @repository.fetch_changesets | |
68 @repository.reload | |
69 | |
70 entries = @repository.entries('subversion_test/[folder_with_brackets]') | |
71 assert_not_nil entries, 'Expect to find entries in folder_with_brackets' | |
72 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets' | |
73 assert_equal 'README.txt', entries.first.name | |
74 end | |
75 | |
76 def test_directory_listing_with_square_brackets_in_base | |
77 @project = Project.find(1) | |
78 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]") | |
79 | |
80 @repository.fetch_changesets | |
81 @repository.reload | |
82 | |
83 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision' | |
84 assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add' | |
85 | |
86 entries = @repository.entries('') | |
87 assert_not_nil entries, 'Expect to find entries' | |
88 assert_equal 1, entries.size, 'Expect a single entry' | |
89 assert_equal 'README.txt', entries.first.name | |
90 end | |
91 else | |
92 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" | |
93 def test_fake; assert true end | |
94 end | |
95 end |