Sha256: eaa0d28d201651886e847d0950d4b24c8184722c9f630dde17f2a23dad011848

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require_relative '../test_helper'

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

		def test_export
			with_git_repository('git') do |git|
				Scm::ScratchDir.new do |dir|
					git.export(dir)
					assert_equal ['.','..','.gitignore','COPYING','README','helloworld.c','makefile','ohloh_token'], Dir.entries(dir).sort
				end
			end
		end

		def test_branches
			with_git_repository('git') do |git|
				assert_equal ['master'], git.branches
				assert git.has_branch?('master')
			end
		end

		def test_ls_tree
			with_git_repository('git') do |git|
				assert_equal ['.gitignore','COPYING','README','helloworld.c','makefile','ohloh_token'], git.ls_tree(git.head_token).sort
			end
		end

		def test_is_merge_commit
			with_git_repository('git_walk') do |git|
				assert git.is_merge_commit?(Scm::Commit.new(:token => 'f264fb40c340a415b305ac1f0b8f12502aa2788f'))
				assert !git.is_merge_commit?(Scm::Commit.new(:token => 'd067161caae2eeedbd74976aeff5c4d8f1ccc946'))
			end
		end

    def test_branches_encoding
      with_git_repository('git_with_invalid_encoding') do |git|
        assert_equal true, git.branches.all? { |branch| branch.valid_encoding? }
      end
    end

    # `git ls-tree` returns filenames in valid utf8 regardless of their original form.
    def test_ls_tree_encoding
      with_git_repository('git_with_invalid_encoding') do |git|
        assert_equal true, git.ls_tree.all? { |filename| filename.valid_encoding? }
      end
    end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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