1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
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.
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.
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.
18 require File.dirname(__FILE__) + '/../test_helper'
20 class RepositoryBazaarTest < ActiveSupport::TestCase
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
25 REPOSITORY_PATH.gsub!(/\/+/, '/')
28 @project = Project.find(1)
29 assert @repository = Repository::Bazaar.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}")
32 if File.directory?(REPOSITORY_PATH)
33 def test_fetch_changesets_from_scratch
34 @repository.fetch_changesets
37 assert_equal 4, @repository.changesets.count
38 assert_equal 9, @repository.changes.count
39 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
42 def test_fetch_changesets_incremental
43 @repository.fetch_changesets
44 # Remove changesets with revision > 5
45 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
47 assert_equal 2, @repository.changesets.count
49 @repository.fetch_changesets
50 assert_equal 4, @repository.changesets.count
54 entries = @repository.entries
55 assert_equal 2, entries.size
57 assert_equal 'dir', entries[0].kind
58 assert_equal 'directory', entries[0].name
60 assert_equal 'file', entries[1].kind
61 assert_equal 'doc-mkdir.txt', entries[1].name
64 def test_entries_in_subdirectory
65 entries = @repository.entries('directory')
66 assert_equal 3, entries.size
68 assert_equal 'file', entries.last.kind
69 assert_equal 'edit.png', entries.last.name
73 cat = @repository.scm.cat('directory/document.txt')
74 assert cat =~ /Write the contents of a file as of a given revision to standard output/
78 annotate = @repository.scm.annotate('doc-mkdir.txt')
79 assert_equal 17, annotate.lines.size
80 assert_equal 1, annotate.revisions[0].identifier
81 assert_equal 'jsmith@', annotate.revisions[0].author
82 assert_equal 'mkdir', annotate.lines[0]
85 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
86 def test_fake; assert true end