annotate test/unit/.svn/text-base/repository_bazaar_test.rb.svn-base @ 36:de76cd3e8c8e cc-branches

* Probably abortive experiments in extracting the branch from Hg
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 20 Oct 2010 10:07:29 +0100
parents 513646585e45
children af80e5618e9b
rev   line source
Chris@0 1 # redMine - project management software
Chris@0 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 require File.dirname(__FILE__) + '/../test_helper'
Chris@0 19
Chris@0 20 class RepositoryBazaarTest < ActiveSupport::TestCase
Chris@0 21 fixtures :projects
Chris@0 22
Chris@0 23 # No '..' in the repository path
Chris@0 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
Chris@0 25 REPOSITORY_PATH.gsub!(/\/+/, '/')
Chris@0 26
Chris@0 27 def setup
Chris@0 28 @project = Project.find(1)
Chris@0 29 assert @repository = Repository::Bazaar.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}")
Chris@0 30 end
Chris@0 31
Chris@0 32 if File.directory?(REPOSITORY_PATH)
Chris@0 33 def test_fetch_changesets_from_scratch
Chris@0 34 @repository.fetch_changesets
Chris@0 35 @repository.reload
Chris@0 36
Chris@0 37 assert_equal 4, @repository.changesets.count
Chris@0 38 assert_equal 9, @repository.changes.count
Chris@0 39 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
Chris@0 40 end
Chris@0 41
Chris@0 42 def test_fetch_changesets_incremental
Chris@0 43 @repository.fetch_changesets
Chris@0 44 # Remove changesets with revision > 5
Chris@0 45 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
Chris@0 46 @repository.reload
Chris@0 47 assert_equal 2, @repository.changesets.count
Chris@0 48
Chris@0 49 @repository.fetch_changesets
Chris@0 50 assert_equal 4, @repository.changesets.count
Chris@0 51 end
Chris@0 52
Chris@0 53 def test_entries
Chris@0 54 entries = @repository.entries
Chris@0 55 assert_equal 2, entries.size
Chris@0 56
Chris@0 57 assert_equal 'dir', entries[0].kind
Chris@0 58 assert_equal 'directory', entries[0].name
Chris@0 59
Chris@0 60 assert_equal 'file', entries[1].kind
Chris@0 61 assert_equal 'doc-mkdir.txt', entries[1].name
Chris@0 62 end
Chris@0 63
Chris@0 64 def test_entries_in_subdirectory
Chris@0 65 entries = @repository.entries('directory')
Chris@0 66 assert_equal 3, entries.size
Chris@0 67
Chris@0 68 assert_equal 'file', entries.last.kind
Chris@0 69 assert_equal 'edit.png', entries.last.name
Chris@0 70 end
Chris@0 71
Chris@0 72 def test_cat
Chris@0 73 cat = @repository.scm.cat('directory/document.txt')
Chris@0 74 assert cat =~ /Write the contents of a file as of a given revision to standard output/
Chris@0 75 end
Chris@0 76
Chris@0 77 def test_annotate
Chris@0 78 annotate = @repository.scm.annotate('doc-mkdir.txt')
Chris@0 79 assert_equal 17, annotate.lines.size
Chris@0 80 assert_equal 1, annotate.revisions[0].identifier
Chris@0 81 assert_equal 'jsmith@', annotate.revisions[0].author
Chris@0 82 assert_equal 'mkdir', annotate.lines[0]
Chris@0 83 end
Chris@0 84 else
Chris@0 85 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
Chris@0 86 def test_fake; assert true end
Chris@0 87 end
Chris@0 88 end