Sha256: 29ea0ccf81f950a29e0a9838bdd6f95f420d84ca70e732015ed473a62f892e19

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require_relative '../test_helper'

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

		def test_export
			with_git_repository('git') do |git|
				OhlohScm::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?(OhlohScm::Commit.new(:token => 'f264fb40c340a415b305ac1f0b8f12502aa2788f'))
				assert !git.is_merge_commit?(OhlohScm::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

2 entries across 2 versions & 1 rubygems

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