##// END OF EJS Templates
scm: bazaar: remove trailing white-spaces from unit model test....
Toshi MARUYAMA -
r5919:685aab7fcb60
parent child
Show More
@@ -1,107 +1,107
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class RepositoryBazaarTest < ActiveSupport::TestCase
20 class RepositoryBazaarTest < ActiveSupport::TestCase
21 fixtures :projects
21 fixtures :projects
22
22
23 # No '..' in the repository path
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') +
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') +
25 '/tmp/test/bazaar_repository/trunk'
25 '/tmp/test/bazaar_repository/trunk'
26 REPOSITORY_PATH.gsub!(/\/+/, '/')
26 REPOSITORY_PATH.gsub!(/\/+/, '/')
27
27
28 def setup
28 def setup
29 @project = Project.find(3)
29 @project = Project.find(3)
30 @repository = Repository::Bazaar.create(
30 @repository = Repository::Bazaar.create(
31 :project => @project, :url => "file:///#{REPOSITORY_PATH}",
31 :project => @project, :url => "file:///#{REPOSITORY_PATH}",
32 :log_encoding => 'UTF-8')
32 :log_encoding => 'UTF-8')
33 assert @repository
33 assert @repository
34 end
34 end
35
35
36 if File.directory?(REPOSITORY_PATH)
36 if File.directory?(REPOSITORY_PATH)
37 def test_fetch_changesets_from_scratch
37 def test_fetch_changesets_from_scratch
38 @repository.fetch_changesets
38 @repository.fetch_changesets
39 @repository.reload
39 @repository.reload
40
40
41 assert_equal 4, @repository.changesets.count
41 assert_equal 4, @repository.changesets.count
42 assert_equal 9, @repository.changes.count
42 assert_equal 9, @repository.changes.count
43 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
43 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
44 end
44 end
45
45
46 def test_fetch_changesets_incremental
46 def test_fetch_changesets_incremental
47 @repository.fetch_changesets
47 @repository.fetch_changesets
48 # Remove changesets with revision > 5
48 # Remove changesets with revision > 5
49 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
49 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
50 @repository.reload
50 @repository.reload
51 assert_equal 2, @repository.changesets.count
51 assert_equal 2, @repository.changesets.count
52
52
53 @repository.fetch_changesets
53 @repository.fetch_changesets
54 assert_equal 4, @repository.changesets.count
54 assert_equal 4, @repository.changesets.count
55 end
55 end
56
56
57 def test_entries
57 def test_entries
58 entries = @repository.entries
58 entries = @repository.entries
59 assert_equal 2, entries.size
59 assert_equal 2, entries.size
60
60
61 assert_equal 'dir', entries[0].kind
61 assert_equal 'dir', entries[0].kind
62 assert_equal 'directory', entries[0].name
62 assert_equal 'directory', entries[0].name
63
63
64 assert_equal 'file', entries[1].kind
64 assert_equal 'file', entries[1].kind
65 assert_equal 'doc-mkdir.txt', entries[1].name
65 assert_equal 'doc-mkdir.txt', entries[1].name
66 end
66 end
67
67
68 def test_entries_in_subdirectory
68 def test_entries_in_subdirectory
69 entries = @repository.entries('directory')
69 entries = @repository.entries('directory')
70 assert_equal 3, entries.size
70 assert_equal 3, entries.size
71
71
72 assert_equal 'file', entries.last.kind
72 assert_equal 'file', entries.last.kind
73 assert_equal 'edit.png', entries.last.name
73 assert_equal 'edit.png', entries.last.name
74 end
74 end
75
75
76 def test_previous
76 def test_previous
77 @repository.fetch_changesets
77 @repository.fetch_changesets
78 @repository.reload
78 @repository.reload
79 changeset = @repository.find_changeset_by_name('3')
79 changeset = @repository.find_changeset_by_name('3')
80 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
80 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
81 end
81 end
82
82
83 def test_previous_nil
83 def test_previous_nil
84 @repository.fetch_changesets
84 @repository.fetch_changesets
85 @repository.reload
85 @repository.reload
86 changeset = @repository.find_changeset_by_name('1')
86 changeset = @repository.find_changeset_by_name('1')
87 assert_nil changeset.previous
87 assert_nil changeset.previous
88 end
88 end
89
89
90 def test_next
90 def test_next
91 @repository.fetch_changesets
91 @repository.fetch_changesets
92 @repository.reload
92 @repository.reload
93 changeset = @repository.find_changeset_by_name('2')
93 changeset = @repository.find_changeset_by_name('2')
94 assert_equal @repository.find_changeset_by_name('3'), changeset.next
94 assert_equal @repository.find_changeset_by_name('3'), changeset.next
95 end
95 end
96
96
97 def test_next_nil
97 def test_next_nil
98 @repository.fetch_changesets
98 @repository.fetch_changesets
99 @repository.reload
99 @repository.reload
100 changeset = @repository.find_changeset_by_name('4')
100 changeset = @repository.find_changeset_by_name('4')
101 assert_nil changeset.next
101 assert_nil changeset.next
102 end
102 end
103 else
103 else
104 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
104 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
105 def test_fake; assert true end
105 def test_fake; assert true end
106 end
106 end
107 end
107 end
General Comments 0
You need to be logged in to leave comments. Login now