##// END OF EJS Templates
scm: bazaar: add changesets order test in unit model test....
Toshi MARUYAMA -
r5028:7ffdd961e9f9
parent child
Show More
@@ -1,78 +1,106
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 RepositoryBazaarTest < 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/bazaar_repository'
25 25 REPOSITORY_PATH.gsub!(/\/+/, '/')
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 @repository.fetch_changesets
38 38 @repository.reload
39 39
40 40 assert_equal 4, @repository.changesets.count
41 41 assert_equal 9, @repository.changes.count
42 42 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
43 43 end
44 44
45 45 def test_fetch_changesets_incremental
46 46 @repository.fetch_changesets
47 47 # Remove changesets with revision > 5
48 48 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
49 49 @repository.reload
50 50 assert_equal 2, @repository.changesets.count
51 51
52 52 @repository.fetch_changesets
53 53 assert_equal 4, @repository.changesets.count
54 54 end
55 55
56 56 def test_entries
57 57 entries = @repository.entries
58 58 assert_equal 2, entries.size
59 59
60 60 assert_equal 'dir', entries[0].kind
61 61 assert_equal 'directory', entries[0].name
62 62
63 63 assert_equal 'file', entries[1].kind
64 64 assert_equal 'doc-mkdir.txt', entries[1].name
65 65 end
66 66
67 67 def test_entries_in_subdirectory
68 68 entries = @repository.entries('directory')
69 69 assert_equal 3, entries.size
70 70
71 71 assert_equal 'file', entries.last.kind
72 72 assert_equal 'edit.png', entries.last.name
73 73 end
74
75 def test_previous
76 @repository.fetch_changesets
77 @repository.reload
78 changeset = @repository.find_changeset_by_name('3')
79 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
80 end
81
82 def test_previous_nil
83 @repository.fetch_changesets
84 @repository.reload
85 changeset = @repository.find_changeset_by_name('1')
86 assert_nil changeset.previous
87 end
88
89 def test_next
90 @repository.fetch_changesets
91 @repository.reload
92 changeset = @repository.find_changeset_by_name('2')
93 assert_equal @repository.find_changeset_by_name('3'), changeset.next
94 end
95
96 def test_next_nil
97 @repository.fetch_changesets
98 @repository.reload
99 changeset = @repository.find_changeset_by_name('4')
100 assert_nil changeset.next
101 end
74 102 else
75 103 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
76 104 def test_fake; assert true end
77 105 end
78 106 end
General Comments 0
You need to be logged in to leave comments. Login now