##// END OF EJS Templates
Rails3: scm: bazaar: fix error of test_fetch_changesets_incremental at unit model test...
Toshi MARUYAMA -
r6953:1a99a5a64a79
parent child
Show More
@@ -1,107 +1,111
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 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 RepositoryBazaarTest < ActiveSupport::TestCase
21 21 fixtures :projects
22 22
23 23 REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository/trunk').to_s
24 24 REPOSITORY_PATH.gsub!(/\/+/, '/')
25 25 NUM_REV = 4
26 26
27 27 def setup
28 28 @project = Project.find(3)
29 29 @repository = Repository::Bazaar.create(
30 30 :project => @project, :url => "file:///#{REPOSITORY_PATH}",
31 31 :log_encoding => 'UTF-8')
32 32 assert @repository
33 33 end
34 34
35 35 if File.directory?(REPOSITORY_PATH)
36 36 def test_fetch_changesets_from_scratch
37 37 assert_equal 0, @repository.changesets.count
38 38 @repository.fetch_changesets
39 39 @project.reload
40 40
41 41 assert_equal NUM_REV, @repository.changesets.count
42 42 assert_equal 9, @repository.changes.count
43 43 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
44 44 end
45 45
46 46 def test_fetch_changesets_incremental
47 assert_equal 0, @repository.changesets.count
47 48 @repository.fetch_changesets
49 @project.reload
50 assert_equal NUM_REV, @repository.changesets.count
48 51 # Remove changesets with revision > 5
49 52 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
50 @repository.reload
53 @project.reload
51 54 assert_equal 2, @repository.changesets.count
52 55
53 56 @repository.fetch_changesets
54 assert_equal 4, @repository.changesets.count
57 @project.reload
58 assert_equal NUM_REV, @repository.changesets.count
55 59 end
56 60
57 61 def test_entries
58 62 entries = @repository.entries
59 63 assert_equal 2, entries.size
60 64
61 65 assert_equal 'dir', entries[0].kind
62 66 assert_equal 'directory', entries[0].name
63 67
64 68 assert_equal 'file', entries[1].kind
65 69 assert_equal 'doc-mkdir.txt', entries[1].name
66 70 end
67 71
68 72 def test_entries_in_subdirectory
69 73 entries = @repository.entries('directory')
70 74 assert_equal 3, entries.size
71 75
72 76 assert_equal 'file', entries.last.kind
73 77 assert_equal 'edit.png', entries.last.name
74 78 end
75 79
76 80 def test_previous
77 81 @repository.fetch_changesets
78 82 @repository.reload
79 83 changeset = @repository.find_changeset_by_name('3')
80 84 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
81 85 end
82 86
83 87 def test_previous_nil
84 88 @repository.fetch_changesets
85 89 @repository.reload
86 90 changeset = @repository.find_changeset_by_name('1')
87 91 assert_nil changeset.previous
88 92 end
89 93
90 94 def test_next
91 95 @repository.fetch_changesets
92 96 @repository.reload
93 97 changeset = @repository.find_changeset_by_name('2')
94 98 assert_equal @repository.find_changeset_by_name('3'), changeset.next
95 99 end
96 100
97 101 def test_next_nil
98 102 @repository.fetch_changesets
99 103 @repository.reload
100 104 changeset = @repository.find_changeset_by_name('4')
101 105 assert_nil changeset.next
102 106 end
103 107 else
104 108 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
105 109 def test_fake; assert true end
106 110 end
107 111 end
General Comments 0
You need to be logged in to leave comments. Login now