##// END OF EJS Templates
Fixes random failure (database may not return changes in the order expected in the test)....
Fixes random failure (database may not return changes in the order expected in the test). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4674 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r4554:a9eea27742dd
r4554:a9eea27742dd
Show More
repository_mercurial_test.rb
146 lines | 5.2 KiB | text/x-ruby | RubyLexer
/ test / unit / repository_mercurial_test.rb
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978 # redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class RepositoryMercurialTest < ActiveSupport::TestCase
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978 fixtures :projects
# No '..' in the repository path
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
def setup
@project = Project.find(1)
assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH)
end
if File.directory?(REPOSITORY_PATH)
def test_fetch_changesets_from_scratch
@repository.fetch_changesets
@repository.reload
Toshi MARUYAMA
scm: mercurial: update test repository for following issues and fix tests....
r4514 assert_equal 17, @repository.changesets.count
assert_equal 25, @repository.changes.count
Toshi MARUYAMA
scm: mercurial: accept both of revision and nodeid as changeset id (#3724)....
r4534 assert_equal "Initial import.\nThe repository contains 3 files.",
@repository.changesets.find_by_revision('0').comments
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978 end
def test_fetch_changesets_incremental
@repository.fetch_changesets
# Remove changesets with revision > 2
Jean-Philippe Lang
Postgresql 8.3 compatibility fix (#834)....
r1348 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978 @repository.reload
assert_equal 3, @repository.changesets.count
@repository.fetch_changesets
Toshi MARUYAMA
scm: mercurial: update test repository for following issues and fix tests....
r4514 assert_equal 17, @repository.changesets.count
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978 end
Jean-Philippe Lang
Mercurial adapter improvements (patch #1199 by Pierre Paysant-Le Roux)....
r1485
def test_entries
assert_equal 2, @repository.entries("sources", 2).size
Toshi MARUYAMA
scm: mercurial: accept both of revision and nodeid as changeset id (#3724)....
r4534 assert_equal 2, @repository.entries("sources", '400bb8672109').size
Jean-Philippe Lang
Mercurial adapter improvements (patch #1199 by Pierre Paysant-Le Roux)....
r1485 assert_equal 1, @repository.entries("sources", 3).size
Toshi MARUYAMA
scm: mercurial: accept both of revision and nodeid as changeset id (#3724)....
r4534 assert_equal 1, @repository.entries("sources", 'b3a615152df8').size
Jean-Philippe Lang
Mercurial adapter improvements (patch #1199 by Pierre Paysant-Le Roux)....
r1485 end
def test_locate_on_outdated_repository
assert_equal 1, @repository.entries("images", 0).size
assert_equal 2, @repository.entries("images").size
assert_equal 2, @repository.entries("images", 2).size
end
Jean-Philippe Lang
Fixes: Mercurial adapter loses seconds of commit times (#6656)....
r4447 def test_isodatesec
# Template keyword 'isodatesec' supported in Mercurial 1.0 and higher
if @repository.scm.class.client_version_above?([1, 0])
@repository.fetch_changesets
@repository.reload
rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52)
assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on
end
end
Toshi MARUYAMA
Fixed: repository: mercurial: sort changesets by revision (#3449, #3567)....
r4491
def test_changeset_order_by_revision
@repository.fetch_changesets
@repository.reload
c0 = @repository.latest_changeset
c1 = @repository.changesets.find_by_revision('0')
# sorted by revision (id), not by date
assert c0.revision.to_i > c1.revision.to_i
assert c0.committed_on < c1.committed_on
end
Toshi MARUYAMA
scm: mercurial: add some tests at unit and functional test....
r4515
def test_latest_changesets
@repository.fetch_changesets
@repository.reload
# with_limit
changesets = @repository.latest_changesets('', nil, 2)
assert_equal @repository.latest_changesets('', nil)[0, 2], changesets
# with_filepath
changesets = @repository.latest_changesets('/sql_escape/percent%dir/percent%file1.txt', nil)
assert_equal %w|11 10 9|, changesets.collect(&:revision)
changesets = @repository.latest_changesets('/sql_escape/underscore_dir/understrike_file.txt', nil)
assert_equal %w|12 9|, changesets.collect(&:revision)
end
Toshi MARUYAMA
scm: mercurial: add unit test for copied file (#7064)....
r4516
def test_copied_files
@repository.fetch_changesets
@repository.reload
cs1 = @repository.changesets.find_by_revision('13')
Jean-Philippe Lang
Adds assertion to prevent error in test....
r4524 assert_not_nil cs1
Jean-Philippe Lang
Fixes random failure (database may not return changes in the order expected in the test)....
r4554 c1 = cs1.changes.sort_by(&:path)
Toshi MARUYAMA
scm: mercurial: add unit test for copied file (#7064)....
r4516 assert_equal 2, c1.size
assert_equal 'A', c1[0].action
assert_equal '/sql_escape/percent%dir/percentfile1.txt', c1[0].path
assert_equal '/sql_escape/percent%dir/percent%file1.txt', c1[0].from_path
assert_equal 'A', c1[1].action
assert_equal '/sql_escape/underscore_dir/understrike-file.txt', c1[1].path
assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path
cs2 = @repository.changesets.find_by_revision('15')
c2 = cs2.changes
assert_equal 1, c2.size
assert_equal 'A', c2[0].action
assert_equal '/README (1)[2]&,%.-3_4', c2[0].path
assert_equal '/README', c2[0].from_path
end
Toshi MARUYAMA
scm: mercurial: accept both of revision and nodeid as changeset id (#3724)....
r4534
def test_find_changeset_by_name
@repository.fetch_changesets
@repository.reload
%w|2 400bb8672109 400|.each do |r|
Toshi MARUYAMA
scm: mercurial: fix assert_equal parameter order at app unit test_find_changeset_by_name()....
r4535 assert_equal '2', @repository.find_changeset_by_name(r).revision
Toshi MARUYAMA
scm: mercurial: accept both of revision and nodeid as changeset id (#3724)....
r4534 end
end
def test_find_changeset_by_invalid_name
@repository.fetch_changesets
@repository.reload
assert_nil @repository.find_changeset_by_name('100000')
end
Jean-Philippe Lang
Added a Mercurial test repository with unit and functional tests....
r978 else
puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!"
def test_fake; assert true end
end
end