To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / unit / repository_bazaar_test.rb @ 442:753f1380d6bc
History | View | Annotate | Download (3.44 KB)
| 1 | 0:513646585e45 | Chris | # 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 | 119:8661b858af72 | Chris | require File.expand_path('../../test_helper', __FILE__) |
| 19 | 0:513646585e45 | Chris | |
| 20 | class RepositoryBazaarTest < 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/bazaar_repository' |
||
| 25 | REPOSITORY_PATH.gsub!(/\/+/, '/') |
||
| 26 | |||
| 27 | def setup |
||
| 28 | 245:051f544170fe | Chris | @project = Project.find(3) |
| 29 | @repository = Repository::Bazaar.create( |
||
| 30 | :project => @project, :url => "file:///#{REPOSITORY_PATH}", |
||
| 31 | :log_encoding => 'UTF-8') |
||
| 32 | assert @repository
|
||
| 33 | 0:513646585e45 | Chris | end
|
| 34 | 245:051f544170fe | Chris | |
| 35 | 0:513646585e45 | Chris | if File.directory?(REPOSITORY_PATH) |
| 36 | def test_fetch_changesets_from_scratch |
||
| 37 | @repository.fetch_changesets
|
||
| 38 | @repository.reload
|
||
| 39 | |||
| 40 | assert_equal 4, @repository.changesets.count |
||
| 41 | assert_equal 9, @repository.changes.count |
||
| 42 | assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments |
||
| 43 | end
|
||
| 44 | 245:051f544170fe | Chris | |
| 45 | 0:513646585e45 | Chris | def test_fetch_changesets_incremental |
| 46 | @repository.fetch_changesets
|
||
| 47 | # Remove changesets with revision > 5
|
||
| 48 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} |
||
| 49 | @repository.reload
|
||
| 50 | assert_equal 2, @repository.changesets.count |
||
| 51 | |||
| 52 | @repository.fetch_changesets
|
||
| 53 | assert_equal 4, @repository.changesets.count |
||
| 54 | end
|
||
| 55 | 245:051f544170fe | Chris | |
| 56 | 0:513646585e45 | Chris | def test_entries |
| 57 | entries = @repository.entries
|
||
| 58 | assert_equal 2, entries.size
|
||
| 59 | |||
| 60 | assert_equal 'dir', entries[0].kind |
||
| 61 | assert_equal 'directory', entries[0].name |
||
| 62 | |||
| 63 | assert_equal 'file', entries[1].kind |
||
| 64 | assert_equal 'doc-mkdir.txt', entries[1].name |
||
| 65 | end
|
||
| 66 | |||
| 67 | def test_entries_in_subdirectory |
||
| 68 | entries = @repository.entries('directory') |
||
| 69 | assert_equal 3, entries.size
|
||
| 70 | |||
| 71 | assert_equal 'file', entries.last.kind
|
||
| 72 | assert_equal 'edit.png', entries.last.name
|
||
| 73 | end
|
||
| 74 | 441:cbce1fd3b1b7 | Chris | |
| 75 | def test_previous |
||
| 76 | @repository.fetch_changesets
|
||
| 77 | @repository.reload
|
||
| 78 | changeset = @repository.find_changeset_by_name('3') |
||
| 79 | assert_equal @repository.find_changeset_by_name('2'), changeset.previous |
||
| 80 | end
|
||
| 81 | |||
| 82 | def test_previous_nil |
||
| 83 | @repository.fetch_changesets
|
||
| 84 | @repository.reload
|
||
| 85 | changeset = @repository.find_changeset_by_name('1') |
||
| 86 | assert_nil changeset.previous |
||
| 87 | end
|
||
| 88 | |||
| 89 | def test_next |
||
| 90 | @repository.fetch_changesets
|
||
| 91 | @repository.reload
|
||
| 92 | changeset = @repository.find_changeset_by_name('2') |
||
| 93 | assert_equal @repository.find_changeset_by_name('3'), changeset.next |
||
| 94 | end
|
||
| 95 | |||
| 96 | def test_next_nil |
||
| 97 | @repository.fetch_changesets
|
||
| 98 | @repository.reload
|
||
| 99 | changeset = @repository.find_changeset_by_name('4') |
||
| 100 | assert_nil changeset.next |
||
| 101 | end
|
||
| 102 | 0:513646585e45 | Chris | else
|
| 103 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
|
||
| 104 | def test_fake; assert true end |
||
| 105 | end
|
||
| 106 | end |