##// END OF EJS Templates
scm: darcs: add entries test in invalid revision in model....
Toshi MARUYAMA -
r5315:20b33942bad7
parent child
Show More
@@ -1,75 +1,81
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2008 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 RepositoryDarcsTest < 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/darcs_repository'
25 25
26 26 def setup
27 27 @project = Project.find(3)
28 28 @repository = Repository::Darcs.create(
29 29 :project => @project, :url => REPOSITORY_PATH,
30 30 :log_encoding => 'UTF-8')
31 31 assert @repository
32 32 end
33 33
34 34 if File.directory?(REPOSITORY_PATH)
35 35 def test_fetch_changesets_from_scratch
36 36 @repository.fetch_changesets
37 37 @repository.reload
38 38
39 39 assert_equal 6, @repository.changesets.count
40 40 assert_equal 13, @repository.changes.count
41 41 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
42 42 end
43 43
44 44 def test_fetch_changesets_incremental
45 45 @repository.fetch_changesets
46 46 # Remove changesets with revision > 3
47 47 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
48 48 @repository.reload
49 49 assert_equal 3, @repository.changesets.count
50 50
51 51 @repository.fetch_changesets
52 52 assert_equal 6, @repository.changesets.count
53 53 end
54 54
55 def test_entries_invalid_revision
56 @repository.fetch_changesets
57 @repository.reload
58 assert_nil @repository.entries('', '123')
59 end
60
55 61 def test_deleted_files_should_not_be_listed
56 62 @repository.fetch_changesets
57 63 @repository.reload
58 64 entries = @repository.entries('sources')
59 65 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
60 66 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
61 67 end
62 68
63 69 def test_cat
64 70 if @repository.scm.supports_cat?
65 71 @repository.fetch_changesets
66 72 cat = @repository.cat("sources/welcome_controller.rb", 2)
67 73 assert_not_nil cat
68 74 assert cat.include?('class WelcomeController < ApplicationController')
69 75 end
70 76 end
71 77 else
72 78 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
73 79 def test_fake; assert true end
74 80 end
75 81 end
General Comments 0
You need to be logged in to leave comments. Login now