Mercurial > hg > soundsoftware-site
comparison test/unit/repository_mercurial_test.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | af80e5618e9b 8661b858af72 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # redMine - project management software | |
2 # Copyright (C) 2006-2007 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 require File.dirname(__FILE__) + '/../test_helper' | |
19 | |
20 class RepositoryMercurialTest < ActiveSupport::TestCase | |
21 fixtures :projects | |
22 | |
23 # No '..' in the repository path | |
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' | |
25 | |
26 def setup | |
27 @project = Project.find(1) | |
28 assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH) | |
29 end | |
30 | |
31 if File.directory?(REPOSITORY_PATH) | |
32 def test_fetch_changesets_from_scratch | |
33 @repository.fetch_changesets | |
34 @repository.reload | |
35 | |
36 assert_equal 6, @repository.changesets.count | |
37 assert_equal 11, @repository.changes.count | |
38 assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments | |
39 end | |
40 | |
41 def test_fetch_changesets_incremental | |
42 @repository.fetch_changesets | |
43 # Remove changesets with revision > 2 | |
44 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} | |
45 @repository.reload | |
46 assert_equal 3, @repository.changesets.count | |
47 | |
48 @repository.fetch_changesets | |
49 assert_equal 6, @repository.changesets.count | |
50 end | |
51 | |
52 def test_entries | |
53 assert_equal 2, @repository.entries("sources", 2).size | |
54 assert_equal 1, @repository.entries("sources", 3).size | |
55 end | |
56 | |
57 def test_locate_on_outdated_repository | |
58 # Change the working dir state | |
59 %x{hg -R #{REPOSITORY_PATH} up -r 0} | |
60 assert_equal 1, @repository.entries("images", 0).size | |
61 assert_equal 2, @repository.entries("images").size | |
62 assert_equal 2, @repository.entries("images", 2).size | |
63 end | |
64 | |
65 | |
66 def test_cat | |
67 assert @repository.scm.cat("sources/welcome_controller.rb", 2) | |
68 assert_nil @repository.scm.cat("sources/welcome_controller.rb") | |
69 end | |
70 | |
71 else | |
72 puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" | |
73 def test_fake; assert true end | |
74 end | |
75 end |