Commits

Toshi MARUYAMA committed 484a103

rearrange unit tests.

Comments (0)

Files changed (2)

hg-unit-test-rearrange.diff

+# HG changeset patch
+# Parent 2ec329f4ab8c54c851d87e7dde297ea3d8d0b66b
+repository: mercurial: rearrange unit tests.
+
+diff --git a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
+--- a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
++++ b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
+@@ -3,16 +3,14 @@
+ begin
+   require 'mocha'
+   
+-  class MercurialAdapterTest < ActiveSupport::TestCase
++  class MercurialAdapterClassTest < 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 setup
+-      @adapter = Redmine::Scm::Adapters::MercurialAdapter
++      @adapter_class = Redmine::Scm::Adapters::MercurialAdapter
+     end
+     
+     def test_hgversion
+@@ -50,21 +48,40 @@
+         test_template_path_for(v, template)
+       end
+     end
+-    
++
+     private
+-    
++
+     def test_hgversion_for(hgversion, version)
+-      @adapter.expects(:hgversion_from_command_line).returns(hgversion)
+-      assert_equal version, @adapter.hgversion
++      @adapter_class.expects(:hgversion_from_command_line).returns(hgversion)
++      assert_equal version, @adapter_class.hgversion
+     end
+-    
++
+     def test_template_path_for(version, template)
+       assert_equal "#{TEMPLATES_DIR}/#{TEMPLATE_NAME}-#{template}.#{TEMPLATE_EXTENSION}",
+-                   @adapter.template_path_for(version)
+-      assert File.exist?(@adapter.template_path_for(version))
++                   @adapter_class.template_path_for(version)
++      assert File.exist?(@adapter_class.template_path_for(version))
+     end
+   end
+   
+ rescue LoadError
+   def test_fake; assert(false, "Requires mocha to run those tests")  end
+ end
++
++class MercurialAdapterTest < ActiveSupport::TestCase
++  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
++
++  if File.directory?(REPOSITORY_PATH)  
++    def setup
++      @adapter = Redmine::Scm::Adapters::MercurialAdapter.new(REPOSITORY_PATH)
++    end
++
++    def test_cat
++      assert     @adapter.cat("sources/welcome_controller.rb", 2)
++      assert_nil @adapter.cat("sources/welcome_controller.rb")
++    end
++
++  else
++    puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!"
++    def test_fake; assert true end
++  end
++end
+diff --git a/test/unit/repository_mercurial_test.rb b/test/unit/repository_mercurial_test.rb
+--- a/test/unit/repository_mercurial_test.rb
++++ b/test/unit/repository_mercurial_test.rb
+@@ -62,12 +62,6 @@
+       assert_equal 2, @repository.entries("images", 2).size
+     end
+ 
+-
+-    def test_cat
+-      assert @repository.scm.cat("sources/welcome_controller.rb", 2)
+-      assert_nil @repository.scm.cat("sources/welcome_controller.rb")
+-    end
+-
+     def test_isodatesec
+       @repository.fetch_changesets
+       @repository.reload
 hg/version.diff
 hg-isodatesec.patch
 hg-changeset-order.patch
+hg-unit-test-rearrange.diff
 hg-use-scmid.patch/find-changeset.diff
 hg-use-scmid.patch/identifier.diff
 hg-use-scmid.patch/format-identifier.diff