Sha256: 071474842f9012313f5738eca6f72475a9004b922df4de6c4d5c4e917a863205

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require_relative '../test_helper'

module OhlohScm::Adapters
	class FactoryTest < Scm::Test

		def test_factory_hg
			Scm::ScratchDir.new do |path|
				`cd #{path} && hg init`
				hg = Factory.from_path(path)
				assert hg.is_a?(HgAdapter)
				assert_equal hg.url, path
			end
		end

		def test_factory_bzr
			Scm::ScratchDir.new do |path|
				`cd #{path} && bzr init`
				bzr = Factory.from_path(path)
				assert bzr.is_a?(BzrAdapter)
				assert_equal bzr.url, path
			end
		end

		def test_factory_git
			Scm::ScratchDir.new do |path|
				`cd #{path} && git init`
				git = Factory.from_path(path)
				assert git.is_a?(GitAdapter)
				assert_equal git.url, path
			end
		end

		def test_factory_svn
			Scm::ScratchDir.new do |path|
				`cd #{path} && svnadmin create foo`
				svn = Factory.from_path(File.join(path, 'foo'))
				assert svn.is_a?(SvnAdapter)
				assert_equal svn.url, 'file://' + File.expand_path(File.join(path, 'foo'))
			end
		end

		def test_factory_svn_checkout
			Scm::ScratchDir.new do |path|
				`cd #{path} && svnadmin create foo`
				`cd #{path} && svn co file://#{File.expand_path(File.join(path, 'foo'))} bar`
				svn = Factory.from_path(File.join(path, 'bar'))
				assert svn.is_a?(SvnAdapter)
				# Note that even though we gave checkout dir 'bar' to the factory,
				# we get back a link to the original repo at 'foo'
				assert_equal svn.url, 'file://' + File.expand_path(File.join(path, 'foo'))
			end
		end

		def test_factory_from_cvs_checkout
			with_cvs_repository('cvs', 'simple') do |cvs|
				Scm::ScratchDir.new do |path|
					`cd #{path} && cvsnt -d #{File.expand_path(cvs.url)} co simple 2> /dev/null`
					factory_response = Factory.from_path(File.join(path, 'simple'))
					assert factory_response.is_a?(CvsAdapter)
					assert_equal cvs.url, factory_response.url
				end
			end
		end

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ohloh_scm-2.0.0 test/unit/adapter_factory_test.rb