Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/repository_bazaar_test.rb.svn-base @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 8661b858af72 |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
17 | 17 |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 | 19 |
20 class RepositoryBazaarTest < ActiveSupport::TestCase | 20 class RepositoryBazaarTest < ActiveSupport::TestCase |
21 fixtures :projects | 21 fixtures :projects |
22 | 22 |
23 # No '..' in the repository path | 23 # No '..' in the repository path |
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository' | 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository' |
25 REPOSITORY_PATH.gsub!(/\/+/, '/') | 25 REPOSITORY_PATH.gsub!(/\/+/, '/') |
26 | 26 |
27 def setup | 27 def setup |
28 @project = Project.find(1) | 28 @project = Project.find(3) |
29 assert @repository = Repository::Bazaar.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}") | 29 @repository = Repository::Bazaar.create( |
30 :project => @project, :url => "file:///#{REPOSITORY_PATH}", | |
31 :log_encoding => 'UTF-8') | |
32 assert @repository | |
30 end | 33 end |
31 | 34 |
32 if File.directory?(REPOSITORY_PATH) | 35 if File.directory?(REPOSITORY_PATH) |
33 def test_fetch_changesets_from_scratch | 36 def test_fetch_changesets_from_scratch |
34 @repository.fetch_changesets | 37 @repository.fetch_changesets |
35 @repository.reload | 38 @repository.reload |
36 | 39 |
37 assert_equal 4, @repository.changesets.count | 40 assert_equal 4, @repository.changesets.count |
38 assert_equal 9, @repository.changes.count | 41 assert_equal 9, @repository.changes.count |
39 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments | 42 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments |
40 end | 43 end |
41 | 44 |
42 def test_fetch_changesets_incremental | 45 def test_fetch_changesets_incremental |
43 @repository.fetch_changesets | 46 @repository.fetch_changesets |
44 # Remove changesets with revision > 5 | 47 # Remove changesets with revision > 5 |
45 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} | 48 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} |
46 @repository.reload | 49 @repository.reload |
47 assert_equal 2, @repository.changesets.count | 50 assert_equal 2, @repository.changesets.count |
48 | 51 |
49 @repository.fetch_changesets | 52 @repository.fetch_changesets |
50 assert_equal 4, @repository.changesets.count | 53 assert_equal 4, @repository.changesets.count |
51 end | 54 end |
52 | 55 |
53 def test_entries | 56 def test_entries |
54 entries = @repository.entries | 57 entries = @repository.entries |
55 assert_equal 2, entries.size | 58 assert_equal 2, entries.size |
56 | 59 |
57 assert_equal 'dir', entries[0].kind | 60 assert_equal 'dir', entries[0].kind |
66 assert_equal 3, entries.size | 69 assert_equal 3, entries.size |
67 | 70 |
68 assert_equal 'file', entries.last.kind | 71 assert_equal 'file', entries.last.kind |
69 assert_equal 'edit.png', entries.last.name | 72 assert_equal 'edit.png', entries.last.name |
70 end | 73 end |
71 | |
72 def test_cat | |
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/ | |
75 end | |
76 | |
77 def test_annotate | |
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] | |
83 end | |
84 else | 74 else |
85 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" | 75 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" |
86 def test_fake; assert true end | 76 def test_fake; assert true end |
87 end | 77 end |
88 end | 78 end |