##// END OF EJS Templates
scm: filesystem: update test repository for non ascii text files displaying (#6256)....
Toshi MARUYAMA -
r5083:0597adfe5313
parent child
Show More
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,38 +1,38
1
1
2 require File.expand_path('../../../../../../test_helper', __FILE__)
2 require File.expand_path('../../../../../../test_helper', __FILE__)
3
3
4 class FilesystemAdapterTest < ActiveSupport::TestCase
4 class FilesystemAdapterTest < ActiveSupport::TestCase
5
5
6 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'
6 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'
7
7
8 if File.directory?(REPOSITORY_PATH)
8 if File.directory?(REPOSITORY_PATH)
9 def setup
9 def setup
10 @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
10 @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
11 end
11 end
12
12
13 def test_entries
13 def test_entries
14 assert_equal 2, @adapter.entries.size
14 assert_equal 3, @adapter.entries.size
15 assert_equal ["dir", "test"], @adapter.entries.collect(&:name)
15 assert_equal ["dir", "japanese", "test"], @adapter.entries.collect(&:name)
16 assert_equal ["dir", "test"], @adapter.entries(nil).collect(&:name)
16 assert_equal ["dir", "japanese", "test"], @adapter.entries(nil).collect(&:name)
17 assert_equal ["dir", "test"], @adapter.entries("/").collect(&:name)
17 assert_equal ["dir", "japanese", "test"], @adapter.entries("/").collect(&:name)
18 ["dir", "/dir", "/dir/", "dir/"].each do |path|
18 ["dir", "/dir", "/dir/", "dir/"].each do |path|
19 assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
19 assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
20 end
20 end
21 # If y try to use "..", the path is ignored
21 # If y try to use "..", the path is ignored
22 ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
22 ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
23 assert_equal ["dir", "test"], @adapter.entries(path).collect(&:name),
23 assert_equal ["dir", "japanese", "test"], @adapter.entries(path).collect(&:name),
24 ".. must be ignored in path argument"
24 ".. must be ignored in path argument"
25 end
25 end
26 end
26 end
27
27
28 def test_cat
28 def test_cat
29 assert_equal "TEST CAT\n", @adapter.cat("test")
29 assert_equal "TEST CAT\n", @adapter.cat("test")
30 assert_equal "TEST CAT\n", @adapter.cat("/test")
30 assert_equal "TEST CAT\n", @adapter.cat("/test")
31 # Revision number is ignored
31 # Revision number is ignored
32 assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
32 assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
33 end
33 end
34 else
34 else
35 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
35 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
36 def test_fake; assert true end
36 def test_fake; assert true end
37 end
37 end
38 end
38 end
@@ -1,55 +1,55
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 RepositoryFilesystemTest < ActiveSupport::TestCase
20 class RepositoryFilesystemTest < 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/filesystem_repository'
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'
25
25
26 def setup
26 def setup
27 @project = Project.find(3)
27 @project = Project.find(3)
28 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
28 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
29 assert @repository = Repository::Filesystem.create(
29 assert @repository = Repository::Filesystem.create(
30 :project => @project, :url => REPOSITORY_PATH)
30 :project => @project, :url => REPOSITORY_PATH)
31 end
31 end
32
32
33 if File.directory?(REPOSITORY_PATH)
33 if File.directory?(REPOSITORY_PATH)
34 def test_fetch_changesets
34 def test_fetch_changesets
35 @repository.fetch_changesets
35 @repository.fetch_changesets
36 @repository.reload
36 @repository.reload
37
37
38 assert_equal 0, @repository.changesets.count
38 assert_equal 0, @repository.changesets.count
39 assert_equal 0, @repository.changes.count
39 assert_equal 0, @repository.changes.count
40 end
40 end
41
41
42 def test_entries
42 def test_entries
43 assert_equal 2, @repository.entries("", 2).size
43 assert_equal 3, @repository.entries("", 2).size
44 assert_equal 2, @repository.entries("dir", 3).size
44 assert_equal 2, @repository.entries("dir", 3).size
45 end
45 end
46
46
47 def test_cat
47 def test_cat
48 assert_equal "TEST CAT\n", @repository.scm.cat("test")
48 assert_equal "TEST CAT\n", @repository.scm.cat("test")
49 end
49 end
50
50
51 else
51 else
52 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
52 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
53 def test_fake; assert true end
53 def test_fake; assert true end
54 end
54 end
55 end
55 end
General Comments 0
You need to be logged in to leave comments. Login now