Sha256: d9d250651608529d8a34ba5dc3d2c0c4b5b126040e741bcb48a3b7776fa49cec

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require_relative '../test_helper'

module OhlohScm::Adapters
	class GitPushTest < OhlohScm::Test

		def test_hostname
			assert_equal "foo", GitAdapter.new(:url => 'foo:/bar').hostname
			assert_equal "/bar", GitAdapter.new(:url => 'foo:/bar').path

			assert !GitAdapter.new.hostname
			assert !GitAdapter.new(:url => '/bar').hostname
			assert_equal 'http', GitAdapter.new(:url => 'http://www.ohloh.net/bar').hostname
		end

		def test_local
			assert !GitAdapter.new(:url => "foo:/bar").local? # Assuming your machine is not named "foo" :-)
			assert !GitAdapter.new(:url => "http://www.ohloh.net/foo").local?
			assert GitAdapter.new(:url => "src").local?
			assert GitAdapter.new(:url => "/Users/robin/src").local?
			assert GitAdapter.new(:url => "#{`hostname`.strip}:src").local?
			assert GitAdapter.new(:url => "#{`hostname`.strip}:/Users/robin/src").local?
		end

		def test_basic_push
			with_git_repository('git') do |src|
				OhlohScm::ScratchDir.new do |dest_dir|

					dest = GitAdapter.new(:url => dest_dir).normalize
					assert !dest.exist?

					src.push(dest)
					assert dest.exist?
					assert_equal src.log, dest.log

					# Now push again. This tests a different code path!
					File.open(File.join(src.url, 'foo'), 'w') { }
					src.commit_all(OhlohScm::Commit.new)

					src.push(dest)
					assert dest.exist?
					assert_equal src.log, dest.log

				end
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ohloh_scm-2.1.0 test/unit/git_push_test.rb
ohloh_scm-2.0.1 test/unit/git_push_test.rb