@@ -1,68 +1,70 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 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 RepositoryDarcsTest < ActiveSupport::TestCase |
|
20 | class RepositoryDarcsTest < 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\/\.\.}, '') + '/tmp/test/darcs_repository' |
|
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' | |
25 |
|
25 | |||
26 | def setup |
|
26 | def setup | |
27 | @project = Project.find(1) |
|
27 | @project = Project.find(1) | |
28 | assert @repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH) |
|
28 | assert @repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH) | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | if File.directory?(REPOSITORY_PATH) |
|
31 | if File.directory?(REPOSITORY_PATH) | |
32 | def test_fetch_changesets_from_scratch |
|
32 | def test_fetch_changesets_from_scratch | |
33 | @repository.fetch_changesets |
|
33 | @repository.fetch_changesets | |
34 | @repository.reload |
|
34 | @repository.reload | |
35 |
|
35 | |||
36 | assert_equal 6, @repository.changesets.count |
|
36 | assert_equal 6, @repository.changesets.count | |
37 | assert_equal 13, @repository.changes.count |
|
37 | assert_equal 13, @repository.changes.count | |
38 | assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments |
|
38 | assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_fetch_changesets_incremental |
|
41 | def test_fetch_changesets_incremental | |
42 | @repository.fetch_changesets |
|
42 | @repository.fetch_changesets | |
43 | # Remove changesets with revision > 3 |
|
43 | # Remove changesets with revision > 3 | |
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} |
|
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} | |
45 | @repository.reload |
|
45 | @repository.reload | |
46 | assert_equal 3, @repository.changesets.count |
|
46 | assert_equal 3, @repository.changesets.count | |
47 |
|
47 | |||
48 | @repository.fetch_changesets |
|
48 | @repository.fetch_changesets | |
49 | assert_equal 6, @repository.changesets.count |
|
49 | assert_equal 6, @repository.changesets.count | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def test_deleted_files_should_not_be_listed |
|
52 | def test_deleted_files_should_not_be_listed | |
53 | entries = @repository.entries('sources') |
|
53 | entries = @repository.entries('sources') | |
54 | assert entries.detect {|e| e.name == 'watchers_controller.rb'} |
|
54 | assert entries.detect {|e| e.name == 'watchers_controller.rb'} | |
55 | assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} |
|
55 | assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_cat |
|
58 | def test_cat | |
59 |
@repository. |
|
59 | if @repository.scm.supports_cat? | |
60 | cat = @repository.cat("sources/welcome_controller.rb", 2) |
|
60 | @repository.fetch_changesets | |
61 | assert_not_nil cat |
|
61 | cat = @repository.cat("sources/welcome_controller.rb", 2) | |
62 | assert cat.include?('class WelcomeController < ApplicationController') |
|
62 | assert_not_nil cat | |
|
63 | assert cat.include?('class WelcomeController < ApplicationController') | |||
|
64 | end | |||
63 | end |
|
65 | end | |
64 | else |
|
66 | else | |
65 | puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" |
|
67 | puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" | |
66 | def test_fake; assert true end |
|
68 | def test_fake; assert true end | |
67 | end |
|
69 | end | |
68 | end |
|
70 | end |
General Comments 0
You need to be logged in to leave comments.
Login now