@@ -1,93 +1,96 | |||
|
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 RepositoryDarcsTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s |
|
24 | 24 | NUM_REV = 6 |
|
25 | 25 | |
|
26 | 26 | def setup |
|
27 | 27 | @project = Project.find(3) |
|
28 | 28 | @repository = Repository::Darcs.create( |
|
29 | 29 | :project => @project, |
|
30 | 30 | :url => REPOSITORY_PATH, |
|
31 | 31 | :log_encoding => 'UTF-8' |
|
32 | 32 | ) |
|
33 | 33 | assert @repository |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | if File.directory?(REPOSITORY_PATH) |
|
37 | 37 | def test_fetch_changesets_from_scratch |
|
38 | 38 | assert_equal 0, @repository.changesets.count |
|
39 | 39 | @repository.fetch_changesets |
|
40 | 40 | @project.reload |
|
41 | 41 | |
|
42 | 42 | assert_equal NUM_REV, @repository.changesets.count |
|
43 | 43 | assert_equal 13, @repository.changes.count |
|
44 | 44 | assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_fetch_changesets_incremental |
|
48 | 48 | assert_equal 0, @repository.changesets.count |
|
49 | 49 | @repository.fetch_changesets |
|
50 | 50 | @project.reload |
|
51 | 51 | assert_equal NUM_REV, @repository.changesets.count |
|
52 | 52 | |
|
53 | 53 | # Remove changesets with revision > 3 |
|
54 | 54 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} |
|
55 | 55 | @project.reload |
|
56 | 56 | assert_equal 3, @repository.changesets.count |
|
57 | 57 | |
|
58 | 58 | @repository.fetch_changesets |
|
59 | 59 | @project.reload |
|
60 | 60 | assert_equal NUM_REV, @repository.changesets.count |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | def test_entries_invalid_revision |
|
64 | 64 | assert_equal 0, @repository.changesets.count |
|
65 | 65 | @repository.fetch_changesets |
|
66 | 66 | @project.reload |
|
67 | 67 | assert_equal NUM_REV, @repository.changesets.count |
|
68 | 68 | assert_nil @repository.entries('', '123') |
|
69 | 69 | end |
|
70 | 70 | |
|
71 | 71 | def test_deleted_files_should_not_be_listed |
|
72 | 72 | assert_equal 0, @repository.changesets.count |
|
73 | 73 | @repository.fetch_changesets |
|
74 | 74 | @project.reload |
|
75 | 75 | assert_equal NUM_REV, @repository.changesets.count |
|
76 | 76 | entries = @repository.entries('sources') |
|
77 | 77 | assert entries.detect {|e| e.name == 'watchers_controller.rb'} |
|
78 | 78 | assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} |
|
79 | 79 | end |
|
80 | 80 | |
|
81 | 81 | def test_cat |
|
82 | 82 | if @repository.scm.supports_cat? |
|
83 | assert_equal 0, @repository.changesets.count | |
|
83 | 84 | @repository.fetch_changesets |
|
85 | @project.reload | |
|
86 | assert_equal NUM_REV, @repository.changesets.count | |
|
84 | 87 | cat = @repository.cat("sources/welcome_controller.rb", 2) |
|
85 | 88 | assert_not_nil cat |
|
86 | 89 | assert cat.include?('class WelcomeController < ApplicationController') |
|
87 | 90 | end |
|
88 | 91 | end |
|
89 | 92 | else |
|
90 | 93 | puts "Darcs test repository NOT FOUND. Skipping unit tests !!!" |
|
91 | 94 | def test_fake; assert true end |
|
92 | 95 | end |
|
93 | 96 | end |
General Comments 0
You need to be logged in to leave comments.
Login now