##// END OF EJS Templates
scm: bazaar: update test repository (#2799, #4741, #8030)....
Toshi MARUYAMA -
r5812:9fa4fff48ae2
parent child
Show More
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,150 +1,151
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19 require 'repositories_controller'
19 require 'repositories_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end
22 class RepositoriesController; def rescue_action(e) raise e end; end
23
23
24 class RepositoriesBazaarControllerTest < ActionController::TestCase
24 class RepositoriesBazaarControllerTest < ActionController::TestCase
25 fixtures :projects, :users, :roles, :members, :member_roles,
25 fixtures :projects, :users, :roles, :members, :member_roles,
26 :repositories, :enabled_modules
26 :repositories, :enabled_modules
27
27
28 # No '..' in the repository path
28 # No '..' in the repository path
29 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
29 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') +
30 '/tmp/test/bazaar_repository/trunk'
30 PRJ_ID = 3
31 PRJ_ID = 3
31
32
32 def setup
33 def setup
33 @controller = RepositoriesController.new
34 @controller = RepositoriesController.new
34 @request = ActionController::TestRequest.new
35 @request = ActionController::TestRequest.new
35 @response = ActionController::TestResponse.new
36 @response = ActionController::TestResponse.new
36 User.current = nil
37 User.current = nil
37 @project = Project.find(PRJ_ID)
38 @project = Project.find(PRJ_ID)
38 @repository = Repository::Bazaar.create(
39 @repository = Repository::Bazaar.create(
39 :project => @project,
40 :project => @project,
40 :url => REPOSITORY_PATH,
41 :url => REPOSITORY_PATH,
41 :log_encoding => 'UTF-8')
42 :log_encoding => 'UTF-8')
42 assert @repository
43 assert @repository
43 end
44 end
44
45
45 if File.directory?(REPOSITORY_PATH)
46 if File.directory?(REPOSITORY_PATH)
46 def test_browse_root
47 def test_browse_root
47 get :show, :id => PRJ_ID
48 get :show, :id => PRJ_ID
48 assert_response :success
49 assert_response :success
49 assert_template 'show'
50 assert_template 'show'
50 assert_not_nil assigns(:entries)
51 assert_not_nil assigns(:entries)
51 assert_equal 2, assigns(:entries).size
52 assert_equal 2, assigns(:entries).size
52 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
53 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
53 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
54 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
54 end
55 end
55
56
56 def test_browse_directory
57 def test_browse_directory
57 get :show, :id => PRJ_ID, :path => ['directory']
58 get :show, :id => PRJ_ID, :path => ['directory']
58 assert_response :success
59 assert_response :success
59 assert_template 'show'
60 assert_template 'show'
60 assert_not_nil assigns(:entries)
61 assert_not_nil assigns(:entries)
61 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
62 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
62 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
63 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
63 assert_not_nil entry
64 assert_not_nil entry
64 assert_equal 'file', entry.kind
65 assert_equal 'file', entry.kind
65 assert_equal 'directory/edit.png', entry.path
66 assert_equal 'directory/edit.png', entry.path
66 end
67 end
67
68
68 def test_browse_at_given_revision
69 def test_browse_at_given_revision
69 get :show, :id => PRJ_ID, :path => [], :rev => 3
70 get :show, :id => PRJ_ID, :path => [], :rev => 3
70 assert_response :success
71 assert_response :success
71 assert_template 'show'
72 assert_template 'show'
72 assert_not_nil assigns(:entries)
73 assert_not_nil assigns(:entries)
73 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'],
74 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'],
74 assigns(:entries).collect(&:name)
75 assigns(:entries).collect(&:name)
75 end
76 end
76
77
77 def test_changes
78 def test_changes
78 get :changes, :id => PRJ_ID, :path => ['doc-mkdir.txt']
79 get :changes, :id => PRJ_ID, :path => ['doc-mkdir.txt']
79 assert_response :success
80 assert_response :success
80 assert_template 'changes'
81 assert_template 'changes'
81 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
82 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
82 end
83 end
83
84
84 def test_entry_show
85 def test_entry_show
85 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt']
86 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt']
86 assert_response :success
87 assert_response :success
87 assert_template 'entry'
88 assert_template 'entry'
88 # Line 19
89 # Line 19
89 assert_tag :tag => 'th',
90 assert_tag :tag => 'th',
90 :content => /29/,
91 :content => /29/,
91 :attributes => { :class => /line-num/ },
92 :attributes => { :class => /line-num/ },
92 :sibling => { :tag => 'td', :content => /Show help message/ }
93 :sibling => { :tag => 'td', :content => /Show help message/ }
93 end
94 end
94
95
95 def test_entry_download
96 def test_entry_download
96 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'], :format => 'raw'
97 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'], :format => 'raw'
97 assert_response :success
98 assert_response :success
98 # File content
99 # File content
99 assert @response.body.include?('Show help message')
100 assert @response.body.include?('Show help message')
100 end
101 end
101
102
102 def test_directory_entry
103 def test_directory_entry
103 get :entry, :id => PRJ_ID, :path => ['directory']
104 get :entry, :id => PRJ_ID, :path => ['directory']
104 assert_response :success
105 assert_response :success
105 assert_template 'show'
106 assert_template 'show'
106 assert_not_nil assigns(:entry)
107 assert_not_nil assigns(:entry)
107 assert_equal 'directory', assigns(:entry).name
108 assert_equal 'directory', assigns(:entry).name
108 end
109 end
109
110
110 def test_diff
111 def test_diff
111 # Full diff of changeset 3
112 # Full diff of changeset 3
112 get :diff, :id => PRJ_ID, :rev => 3
113 get :diff, :id => PRJ_ID, :rev => 3
113 assert_response :success
114 assert_response :success
114 assert_template 'diff'
115 assert_template 'diff'
115 # Line 11 removed
116 # Line 11 removed
116 assert_tag :tag => 'th',
117 assert_tag :tag => 'th',
117 :content => /11/,
118 :content => /11/,
118 :sibling => { :tag => 'td',
119 :sibling => { :tag => 'td',
119 :attributes => { :class => /diff_out/ },
120 :attributes => { :class => /diff_out/ },
120 :content => /Display more information/ }
121 :content => /Display more information/ }
121 end
122 end
122
123
123 def test_annotate
124 def test_annotate
124 get :annotate, :id => PRJ_ID, :path => ['doc-mkdir.txt']
125 get :annotate, :id => PRJ_ID, :path => ['doc-mkdir.txt']
125 assert_response :success
126 assert_response :success
126 assert_template 'annotate'
127 assert_template 'annotate'
127 assert_tag :tag => 'th', :content => '2',
128 assert_tag :tag => 'th', :content => '2',
128 :sibling => {
129 :sibling => {
129 :tag => 'td',
130 :tag => 'td',
130 :child => {
131 :child => {
131 :tag => 'a',
132 :tag => 'a',
132 :content => /3/
133 :content => /3/
133 }
134 }
134 },
135 },
135 :sibling => { :tag => 'td', :content => /jsmith/ }
136 :sibling => { :tag => 'td', :content => /jsmith/ }
136 assert_tag :tag => 'th', :content => '2',
137 assert_tag :tag => 'th', :content => '2',
137 :sibling => {
138 :sibling => {
138 :tag => 'td',
139 :tag => 'td',
139 :child => {
140 :child => {
140 :tag => 'a',
141 :tag => 'a',
141 :content => /3/
142 :content => /3/
142 }
143 }
143 },
144 },
144 :sibling => { :tag => 'td', :content => /Main purpose/ }
145 :sibling => { :tag => 'td', :content => /Main purpose/ }
145 end
146 end
146 else
147 else
147 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
148 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
148 def test_fake; assert true end
149 def test_fake; assert true end
149 end
150 end
150 end
151 end
@@ -1,132 +1,133
1 require File.expand_path('../../../../../../test_helper', __FILE__)
1 require File.expand_path('../../../../../../test_helper', __FILE__)
2 begin
2 begin
3 require 'mocha'
3 require 'mocha'
4
4
5 class BazaarAdapterTest < ActiveSupport::TestCase
5 class BazaarAdapterTest < ActiveSupport::TestCase
6
6
7 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
7 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') +
8 '/tmp/test/bazaar_repository/trunk'
8 REPOSITORY_PATH.gsub!(/\/+/, '/')
9 REPOSITORY_PATH.gsub!(/\/+/, '/')
9
10
10 if File.directory?(REPOSITORY_PATH)
11 if File.directory?(REPOSITORY_PATH)
11 def setup
12 def setup
12 @adapter = Redmine::Scm::Adapters::BazaarAdapter.new(REPOSITORY_PATH)
13 @adapter = Redmine::Scm::Adapters::BazaarAdapter.new(REPOSITORY_PATH)
13 end
14 end
14
15
15 def test_scm_version
16 def test_scm_version
16 to_test = { "Bazaar (bzr) 2.1.2\n" => [2,1,2],
17 to_test = { "Bazaar (bzr) 2.1.2\n" => [2,1,2],
17 "2.1.1\n1.7\n1.8" => [2,1,1],
18 "2.1.1\n1.7\n1.8" => [2,1,1],
18 "2.0.1\r\n1.8.1\r\n1.9.1" => [2,0,1]}
19 "2.0.1\r\n1.8.1\r\n1.9.1" => [2,0,1]}
19 to_test.each do |s, v|
20 to_test.each do |s, v|
20 test_scm_version_for(s, v)
21 test_scm_version_for(s, v)
21 end
22 end
22 end
23 end
23
24
24 def test_cat
25 def test_cat
25 cat = @adapter.cat('directory/document.txt')
26 cat = @adapter.cat('directory/document.txt')
26 assert cat =~ /Write the contents of a file as of a given revision to standard output/
27 assert cat =~ /Write the contents of a file as of a given revision to standard output/
27 end
28 end
28
29
29 def test_cat_path_invalid
30 def test_cat_path_invalid
30 assert_nil @adapter.cat('invalid')
31 assert_nil @adapter.cat('invalid')
31 end
32 end
32
33
33 def test_cat_revision_invalid
34 def test_cat_revision_invalid
34 assert_nil @adapter.cat('doc-mkdir.txt', '12345678')
35 assert_nil @adapter.cat('doc-mkdir.txt', '12345678')
35 end
36 end
36
37
37 def test_diff_path_invalid
38 def test_diff_path_invalid
38 assert_equal [], @adapter.diff('invalid', 1)
39 assert_equal [], @adapter.diff('invalid', 1)
39 end
40 end
40
41
41 def test_diff_revision_invalid
42 def test_diff_revision_invalid
42 assert_equal [], @adapter.diff(nil, 12345678)
43 assert_equal [], @adapter.diff(nil, 12345678)
43 assert_equal [], @adapter.diff(nil, 12345678, 87654321)
44 assert_equal [], @adapter.diff(nil, 12345678, 87654321)
44 end
45 end
45
46
46 def test_annotate
47 def test_annotate
47 annotate = @adapter.annotate('doc-mkdir.txt')
48 annotate = @adapter.annotate('doc-mkdir.txt')
48 assert_equal 17, annotate.lines.size
49 assert_equal 17, annotate.lines.size
49 assert_equal '1', annotate.revisions[0].identifier
50 assert_equal '1', annotate.revisions[0].identifier
50 assert_equal 'jsmith@', annotate.revisions[0].author
51 assert_equal 'jsmith@', annotate.revisions[0].author
51 assert_equal 'mkdir', annotate.lines[0]
52 assert_equal 'mkdir', annotate.lines[0]
52 end
53 end
53
54
54 def test_annotate_path_invalid
55 def test_annotate_path_invalid
55 assert_nil @adapter.annotate('invalid')
56 assert_nil @adapter.annotate('invalid')
56 end
57 end
57
58
58 def test_annotate_revision_invalid
59 def test_annotate_revision_invalid
59 assert_nil @adapter.annotate('doc-mkdir.txt', '12345678')
60 assert_nil @adapter.annotate('doc-mkdir.txt', '12345678')
60 end
61 end
61
62
62 def test_branch_conf_path
63 def test_branch_conf_path
63 p = "c:\\test\\test\\"
64 p = "c:\\test\\test\\"
64 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
65 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
65 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
66 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
66 p = "c:\\test\\test\\.bzr"
67 p = "c:\\test\\test\\.bzr"
67 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
68 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
68 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
69 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
69 p = "c:\\test\\test\\.bzr\\"
70 p = "c:\\test\\test\\.bzr\\"
70 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
71 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
71 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
72 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
72 p = "c:\\test\\test"
73 p = "c:\\test\\test"
73 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
74 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
74 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
75 assert_equal File.join("c:\\test\\test", ".bzr", "branch", "branch.conf"), bcp
75 p = "\\\\server\\test\\test\\"
76 p = "\\\\server\\test\\test\\"
76 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
77 bcp = Redmine::Scm::Adapters::BazaarAdapter.branch_conf_path(p)
77 assert_equal File.join("\\\\server\\test\\test", ".bzr", "branch", "branch.conf"), bcp
78 assert_equal File.join("\\\\server\\test\\test", ".bzr", "branch", "branch.conf"), bcp
78 end
79 end
79
80
80 def test_append_revisions_only
81 def test_append_revisions_only
81 assert_equal false, @adapter.append_revisions_only
82 assert_equal true, @adapter.append_revisions_only
82 end
83 end
83
84
84 def test_info_not_nil
85 def test_info_not_nil
85 assert_not_nil @adapter.info
86 assert_not_nil @adapter.info
86 end
87 end
87
88
88 def test_info_nil
89 def test_info_nil
89 adpt = Redmine::Scm::Adapters::BazaarAdapter.new(
90 adpt = Redmine::Scm::Adapters::BazaarAdapter.new(
90 "/invalid/invalid/"
91 "/invalid/invalid/"
91 )
92 )
92 assert_nil adpt.info
93 assert_nil adpt.info
93 end
94 end
94
95
95 def test_info
96 def test_info
96 info = @adapter.info
97 info = @adapter.info
97 assert_equal 4, info.lastrev.identifier.to_i
98 assert_equal 4, info.lastrev.identifier.to_i
98 end
99 end
99
100
100 def test_entries_path_invalid
101 def test_entries_path_invalid
101 assert_equal [], @adapter.entries('invalid')
102 assert_equal [], @adapter.entries('invalid')
102 end
103 end
103
104
104 def test_entries_revision_invalid
105 def test_entries_revision_invalid
105 assert_nil @adapter.entries(nil, 12345678)
106 assert_nil @adapter.entries(nil, 12345678)
106 end
107 end
107
108
108 def test_revisions_path_invalid
109 def test_revisions_path_invalid
109 assert_nil @adapter.revisions('invalid')
110 assert_nil @adapter.revisions('invalid')
110 end
111 end
111
112
112 def test_revisions_revision_invalid
113 def test_revisions_revision_invalid
113 assert_nil @adapter.revisions(nil, 12345678)
114 assert_nil @adapter.revisions(nil, 12345678)
114 assert_nil @adapter.revisions(nil, 12345678, 87654321)
115 assert_nil @adapter.revisions(nil, 12345678, 87654321)
115 end
116 end
116
117
117 private
118 private
118
119
119 def test_scm_version_for(scm_command_version, version)
120 def test_scm_version_for(scm_command_version, version)
120 @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version)
121 @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version)
121 assert_equal version, @adapter.class.scm_command_version
122 assert_equal version, @adapter.class.scm_command_version
122 end
123 end
123 else
124 else
124 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
125 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
125 def test_fake; assert true end
126 def test_fake; assert true end
126 end
127 end
127 end
128 end
128 rescue LoadError
129 rescue LoadError
129 class BazaarMochaFake < ActiveSupport::TestCase
130 class BazaarMochaFake < ActiveSupport::TestCase
130 def test_fake; assert(false, "Requires mocha to run those tests") end
131 def test_fake; assert(false, "Requires mocha to run those tests") end
131 end
132 end
132 end
133 end
@@ -1,106 +1,107
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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\/\.\.}, '') +
25 '/tmp/test/bazaar_repository/trunk'
25 REPOSITORY_PATH.gsub!(/\/+/, '/')
26 REPOSITORY_PATH.gsub!(/\/+/, '/')
26
27
27 def setup
28 def setup
28 @project = Project.find(3)
29 @project = Project.find(3)
29 @repository = Repository::Bazaar.create(
30 @repository = Repository::Bazaar.create(
30 :project => @project, :url => "file:///#{REPOSITORY_PATH}",
31 :project => @project, :url => "file:///#{REPOSITORY_PATH}",
31 :log_encoding => 'UTF-8')
32 :log_encoding => 'UTF-8')
32 assert @repository
33 assert @repository
33 end
34 end
34
35
35 if File.directory?(REPOSITORY_PATH)
36 if File.directory?(REPOSITORY_PATH)
36 def test_fetch_changesets_from_scratch
37 def test_fetch_changesets_from_scratch
37 @repository.fetch_changesets
38 @repository.fetch_changesets
38 @repository.reload
39 @repository.reload
39
40
40 assert_equal 4, @repository.changesets.count
41 assert_equal 4, @repository.changesets.count
41 assert_equal 9, @repository.changes.count
42 assert_equal 9, @repository.changes.count
42 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
43 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
43 end
44 end
44
45
45 def test_fetch_changesets_incremental
46 def test_fetch_changesets_incremental
46 @repository.fetch_changesets
47 @repository.fetch_changesets
47 # Remove changesets with revision > 5
48 # Remove changesets with revision > 5
48 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
49 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
49 @repository.reload
50 @repository.reload
50 assert_equal 2, @repository.changesets.count
51 assert_equal 2, @repository.changesets.count
51
52
52 @repository.fetch_changesets
53 @repository.fetch_changesets
53 assert_equal 4, @repository.changesets.count
54 assert_equal 4, @repository.changesets.count
54 end
55 end
55
56
56 def test_entries
57 def test_entries
57 entries = @repository.entries
58 entries = @repository.entries
58 assert_equal 2, entries.size
59 assert_equal 2, entries.size
59
60
60 assert_equal 'dir', entries[0].kind
61 assert_equal 'dir', entries[0].kind
61 assert_equal 'directory', entries[0].name
62 assert_equal 'directory', entries[0].name
62
63
63 assert_equal 'file', entries[1].kind
64 assert_equal 'file', entries[1].kind
64 assert_equal 'doc-mkdir.txt', entries[1].name
65 assert_equal 'doc-mkdir.txt', entries[1].name
65 end
66 end
66
67
67 def test_entries_in_subdirectory
68 def test_entries_in_subdirectory
68 entries = @repository.entries('directory')
69 entries = @repository.entries('directory')
69 assert_equal 3, entries.size
70 assert_equal 3, entries.size
70
71
71 assert_equal 'file', entries.last.kind
72 assert_equal 'file', entries.last.kind
72 assert_equal 'edit.png', entries.last.name
73 assert_equal 'edit.png', entries.last.name
73 end
74 end
74
75
75 def test_previous
76 def test_previous
76 @repository.fetch_changesets
77 @repository.fetch_changesets
77 @repository.reload
78 @repository.reload
78 changeset = @repository.find_changeset_by_name('3')
79 changeset = @repository.find_changeset_by_name('3')
79 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
80 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
80 end
81 end
81
82
82 def test_previous_nil
83 def test_previous_nil
83 @repository.fetch_changesets
84 @repository.fetch_changesets
84 @repository.reload
85 @repository.reload
85 changeset = @repository.find_changeset_by_name('1')
86 changeset = @repository.find_changeset_by_name('1')
86 assert_nil changeset.previous
87 assert_nil changeset.previous
87 end
88 end
88
89
89 def test_next
90 def test_next
90 @repository.fetch_changesets
91 @repository.fetch_changesets
91 @repository.reload
92 @repository.reload
92 changeset = @repository.find_changeset_by_name('2')
93 changeset = @repository.find_changeset_by_name('2')
93 assert_equal @repository.find_changeset_by_name('3'), changeset.next
94 assert_equal @repository.find_changeset_by_name('3'), changeset.next
94 end
95 end
95
96
96 def test_next_nil
97 def test_next_nil
97 @repository.fetch_changesets
98 @repository.fetch_changesets
98 @repository.reload
99 @repository.reload
99 changeset = @repository.find_changeset_by_name('4')
100 changeset = @repository.find_changeset_by_name('4')
100 assert_nil changeset.next
101 assert_nil changeset.next
101 end
102 end
102 else
103 else
103 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
104 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
104 def test_fake; assert true end
105 def test_fake; assert true end
105 end
106 end
106 end
107 end
General Comments 0
You need to be logged in to leave comments. Login now