]> source.dussan.org Git - redmine.git/commitdiff
Moves scm adapters unit tests to a dedicated folder.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 6 Mar 2010 20:35:38 +0000 (20:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 6 Mar 2010 20:35:38 +0000 (20:35 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3551 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/filesystem_adapter_test.rb [deleted file]
test/unit/git_adapter_test.rb [deleted file]
test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb [new file with mode: 0644]
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb [new file with mode: 0644]
test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb [new file with mode: 0644]
test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb [new file with mode: 0644]
test/unit/mercurial_adapter_test.rb [deleted file]
test/unit/subversion_adapter_test.rb [deleted file]

diff --git a/test/unit/filesystem_adapter_test.rb b/test/unit/filesystem_adapter_test.rb
deleted file mode 100644 (file)
index 26e97bd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-require File.dirname(__FILE__) + '/../test_helper'
-
-
-class FilesystemAdapterTest < ActiveSupport::TestCase
-  
-  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'  
-  
-  if File.directory?(REPOSITORY_PATH)    
-    def setup
-      @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
-    end
-    
-    def test_entries
-      assert_equal 2, @adapter.entries.size
-      assert_equal ["dir", "test"], @adapter.entries.collect(&:name)
-      assert_equal ["dir", "test"], @adapter.entries(nil).collect(&:name)
-      assert_equal ["dir", "test"], @adapter.entries("/").collect(&:name)
-      ["dir", "/dir", "/dir/", "dir/"].each do |path|
-        assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
-      end
-      # If y try to use "..", the path is ignored
-      ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
-        assert_equal ["dir", "test"], @adapter.entries(path).collect(&:name), ".. must be ignored in path argument"
-      end
-    end
-    
-    def test_cat
-      assert_equal "TEST CAT\n", @adapter.cat("test")
-      assert_equal "TEST CAT\n", @adapter.cat("/test")
-      # Revision number is ignored
-      assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
-    end
-    
-  else
-    puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
-    def test_fake; assert true end
-  end
-  
-end
-
-
diff --git a/test/unit/git_adapter_test.rb b/test/unit/git_adapter_test.rb
deleted file mode 100644 (file)
index 8bc000c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-class GitAdapterTest < ActiveSupport::TestCase
-  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
-
-  if File.directory?(REPOSITORY_PATH)  
-    def setup
-      @adapter = Redmine::Scm::Adapters::GitAdapter.new(REPOSITORY_PATH)
-    end
-
-    def test_branches
-      assert_equal @adapter.branches, ['master', 'test_branch']
-    end
-
-    def test_getting_all_revisions
-      assert_equal 12, @adapter.revisions('',nil,nil,:all => true).length
-    end
-    
-    def test_annotate
-      annotate = @adapter.annotate('sources/watchers_controller.rb')
-      assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
-      assert_equal 41, annotate.lines.size
-      assert_equal "# This program is free software; you can redistribute it and/or", annotate.lines[4].strip
-      assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", annotate.revisions[4].identifier
-      assert_equal "jsmith", annotate.revisions[4].author
-    end
-    
-    def test_annotate_moved_file
-      annotate = @adapter.annotate('renamed_test.txt')
-      assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
-      assert_equal 2, annotate.lines.size
-    end
-  else
-    puts "Git test repository NOT FOUND. Skipping unit tests !!!"
-    def test_fake; assert true end
-  end
-end
diff --git a/test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb
new file mode 100644 (file)
index 0000000..6e3b4cb
--- /dev/null
@@ -0,0 +1,42 @@
+
+require File.dirname(__FILE__) + '/../../../../../test_helper'
+
+
+class FilesystemAdapterTest < ActiveSupport::TestCase
+  
+  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'  
+  
+  if File.directory?(REPOSITORY_PATH)    
+    def setup
+      @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
+    end
+    
+    def test_entries
+      assert_equal 2, @adapter.entries.size
+      assert_equal ["dir", "test"], @adapter.entries.collect(&:name)
+      assert_equal ["dir", "test"], @adapter.entries(nil).collect(&:name)
+      assert_equal ["dir", "test"], @adapter.entries("/").collect(&:name)
+      ["dir", "/dir", "/dir/", "dir/"].each do |path|
+        assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
+      end
+      # If y try to use "..", the path is ignored
+      ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
+        assert_equal ["dir", "test"], @adapter.entries(path).collect(&:name), ".. must be ignored in path argument"
+      end
+    end
+    
+    def test_cat
+      assert_equal "TEST CAT\n", @adapter.cat("test")
+      assert_equal "TEST CAT\n", @adapter.cat("/test")
+      # Revision number is ignored
+      assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
+    end
+    
+  else
+    puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
+    def test_fake; assert true end
+  end
+  
+end
+
+
diff --git a/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
new file mode 100644 (file)
index 0000000..e3c6337
--- /dev/null
@@ -0,0 +1,37 @@
+require File.dirname(__FILE__) + '/../../../../../test_helper'
+
+class GitAdapterTest < ActiveSupport::TestCase
+  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
+
+  if File.directory?(REPOSITORY_PATH)  
+    def setup
+      @adapter = Redmine::Scm::Adapters::GitAdapter.new(REPOSITORY_PATH)
+    end
+
+    def test_branches
+      assert_equal @adapter.branches, ['master', 'test_branch']
+    end
+
+    def test_getting_all_revisions
+      assert_equal 12, @adapter.revisions('',nil,nil,:all => true).length
+    end
+    
+    def test_annotate
+      annotate = @adapter.annotate('sources/watchers_controller.rb')
+      assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
+      assert_equal 41, annotate.lines.size
+      assert_equal "# This program is free software; you can redistribute it and/or", annotate.lines[4].strip
+      assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", annotate.revisions[4].identifier
+      assert_equal "jsmith", annotate.revisions[4].author
+    end
+    
+    def test_annotate_moved_file
+      annotate = @adapter.annotate('renamed_test.txt')
+      assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
+      assert_equal 2, annotate.lines.size
+    end
+  else
+    puts "Git test repository NOT FOUND. Skipping unit tests !!!"
+    def test_fake; assert true end
+  end
+end
diff --git a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
new file mode 100644 (file)
index 0000000..7396a39
--- /dev/null
@@ -0,0 +1,53 @@
+require File.dirname(__FILE__) + '/../../../../../test_helper'
+begin
+  require 'mocha'
+  
+  class MercurialAdapterTest < ActiveSupport::TestCase
+    
+    TEMPLATES_DIR = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATES_DIR
+    TEMPLATE_NAME = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_NAME
+    TEMPLATE_EXTENSION = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_EXTENSION
+    
+    REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
+    
+    def test_hgversion
+      to_test = { "0.9.5" => [0,9,5],
+                  "1.0" => [1,0],
+                  "1e4ddc9ac9f7+20080325" => nil,
+                  "1.0.1+20080525" => [1,0,1],
+                  "1916e629a29d" => nil}
+      
+      to_test.each do |s, v|
+        test_hgversion_for(s, v)
+      end
+    end
+    
+    def test_template_path
+      to_test = { [0,9,5] => "0.9.5",
+                  [1,0] => "1.0",
+                  [] => "1.0",
+                  [1,0,1] => "1.0"}
+      
+      to_test.each do |v, template|
+        test_template_path_for(v, template)
+      end
+    end
+    
+    private
+    
+    def test_hgversion_for(hgversion, version)
+      Redmine::Scm::Adapters::MercurialAdapter.expects(:hgversion_from_command_line).returns(hgversion)
+      adapter = Redmine::Scm::Adapters::MercurialAdapter
+      assert_equal version, adapter.hgversion
+    end
+    
+    def test_template_path_for(version, template)
+      adapter = Redmine::Scm::Adapters::MercurialAdapter
+      assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}", adapter.template_path_for(version)
+      assert File.exist?(adapter.template_path_for(version))
+    end
+  end
+  
+rescue LoadError
+  def test_fake; assert(false, "Requires mocha to run those tests")  end
+end
diff --git a/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb
new file mode 100644 (file)
index 0000000..e44d12f
--- /dev/null
@@ -0,0 +1,33 @@
+# redMine - project management software
+# Copyright (C) 2006-2008  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+require 'mkmf'
+
+require File.dirname(__FILE__) + '/../../../../../test_helper'
+
+class SubversionAdapterTest < ActiveSupport::TestCase
+  
+  if find_executable0('svn')
+    def test_client_version
+      v = Redmine::Scm::Adapters::SubversionAdapter.client_version
+      assert v.is_a?(Array)
+    end
+  else
+    puts "Subversion binary NOT FOUND. Skipping unit tests !!!"
+    def test_fake; assert true end
+  end
+end
diff --git a/test/unit/mercurial_adapter_test.rb b/test/unit/mercurial_adapter_test.rb
deleted file mode 100644 (file)
index f7b0d3c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-begin
-  require 'mocha'
-  
-  class MercurialAdapterTest < ActiveSupport::TestCase
-    
-    TEMPLATES_DIR = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATES_DIR
-    TEMPLATE_NAME = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_NAME
-    TEMPLATE_EXTENSION = Redmine::Scm::Adapters::MercurialAdapter::TEMPLATE_EXTENSION
-    
-    REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
-    
-    def test_hgversion
-      to_test = { "0.9.5" => [0,9,5],
-                  "1.0" => [1,0],
-                  "1e4ddc9ac9f7+20080325" => nil,
-                  "1.0.1+20080525" => [1,0,1],
-                  "1916e629a29d" => nil}
-      
-      to_test.each do |s, v|
-        test_hgversion_for(s, v)
-      end
-    end
-    
-    def test_template_path
-      to_test = { [0,9,5] => "0.9.5",
-                  [1,0] => "1.0",
-                  [] => "1.0",
-                  [1,0,1] => "1.0"}
-      
-      to_test.each do |v, template|
-        test_template_path_for(v, template)
-      end
-    end
-    
-    private
-    
-    def test_hgversion_for(hgversion, version)
-      Redmine::Scm::Adapters::MercurialAdapter.expects(:hgversion_from_command_line).returns(hgversion)
-      adapter = Redmine::Scm::Adapters::MercurialAdapter
-      assert_equal version, adapter.hgversion
-    end
-    
-    def test_template_path_for(version, template)
-      adapter = Redmine::Scm::Adapters::MercurialAdapter
-      assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}", adapter.template_path_for(version)
-      assert File.exist?(adapter.template_path_for(version))
-    end
-  end
-  
-rescue LoadError
-  def test_fake; assert(false, "Requires mocha to run those tests")  end
-end
diff --git a/test/unit/subversion_adapter_test.rb b/test/unit/subversion_adapter_test.rb
deleted file mode 100644 (file)
index ddef52d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-# redMine - project management software
-# Copyright (C) 2006-2008  Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-require 'mkmf'
-
-require File.dirname(__FILE__) + '/../test_helper'
-
-class SubversionAdapterTest < ActiveSupport::TestCase
-  
-  if find_executable0('svn')
-    def test_client_version
-      v = Redmine::Scm::Adapters::SubversionAdapter.client_version
-      assert v.is_a?(Array)
-    end
-  else
-    puts "Subversion binary NOT FOUND. Skipping unit tests !!!"
-    def test_fake; assert true end
-  end
-end