To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / unit / .svn / text-base / repository_darcs_test.rb.svn-base @ 441:cbce1fd3b1b7

History | View | Annotate | Download (2.81 KB)

1 0:513646585e45 Chris
# redMine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
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
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
18 119:8661b858af72 Chris
require File.expand_path('../../test_helper', __FILE__)
19 0:513646585e45 Chris
20
class RepositoryDarcsTest < ActiveSupport::TestCase
21
  fixtures :projects
22 245:051f544170fe Chris
23 0:513646585e45 Chris
  # No '..' in the repository path
24
  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
25 245:051f544170fe Chris
26 0:513646585e45 Chris
  def setup
27 245:051f544170fe Chris
    @project = Project.find(3)
28
    @repository = Repository::Darcs.create(
29
                      :project => @project, :url => REPOSITORY_PATH,
30
                      :log_encoding => 'UTF-8')
31
    assert @repository
32 0:513646585e45 Chris
  end
33 245:051f544170fe Chris
34 0:513646585e45 Chris
  if File.directory?(REPOSITORY_PATH)
35
    def test_fetch_changesets_from_scratch
36
      @repository.fetch_changesets
37
      @repository.reload
38 245:051f544170fe Chris
39 0:513646585e45 Chris
      assert_equal 6, @repository.changesets.count
40
      assert_equal 13, @repository.changes.count
41
      assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
42
    end
43 245:051f544170fe Chris
44 0:513646585e45 Chris
    def test_fetch_changesets_incremental
45
      @repository.fetch_changesets
46
      # Remove changesets with revision > 3
47
      @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
48
      @repository.reload
49
      assert_equal 3, @repository.changesets.count
50
51
      @repository.fetch_changesets
52
      assert_equal 6, @repository.changesets.count
53
    end
54 245:051f544170fe Chris
55 441:cbce1fd3b1b7 Chris
    def test_entries_invalid_revision
56
      @repository.fetch_changesets
57
      @repository.reload
58
      assert_nil @repository.entries('', '123')
59
    end
60
61 0:513646585e45 Chris
    def test_deleted_files_should_not_be_listed
62 245:051f544170fe Chris
      @repository.fetch_changesets
63
      @repository.reload
64 0:513646585e45 Chris
      entries = @repository.entries('sources')
65
      assert entries.detect {|e| e.name == 'watchers_controller.rb'}
66
      assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
67
    end
68 119:8661b858af72 Chris
69 0:513646585e45 Chris
    def test_cat
70 119:8661b858af72 Chris
      if @repository.scm.supports_cat?
71
        @repository.fetch_changesets
72
        cat = @repository.cat("sources/welcome_controller.rb", 2)
73
        assert_not_nil cat
74
        assert cat.include?('class WelcomeController < ApplicationController')
75
      end
76 0:513646585e45 Chris
    end
77
  else
78
    puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
79
    def test_fake; assert true end
80
  end
81
end