Sha256: 8a12b13e8fbcb45a692b808cd7cbdb02c3ed4427373cda41cc7f351748aaad12

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require_relative '../test_helper'

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

		def test_no_token_returns_nil
			Scm::ScratchDir.new do |dir|
				git = GitAdapter.new(:url => dir).normalize
				assert !git.read_token
				git.init_db
				assert !git.read_token
			end
		end

		def test_write_and_read_token
			Scm::ScratchDir.new do |dir|
				git = GitAdapter.new(:url => dir).normalize
				git.init_db
				git.write_token("FOO")
				assert !git.read_token # Token not valid until committed
				git.commit_all(Scm::Commit.new)
				assert_equal "FOO", git.read_token
			end
		end

		def test_commit_all_includes_write_token
			Scm::ScratchDir.new do |dir|
				git = GitAdapter.new(:url => dir).normalize
				git.init_db
				c = Scm::Commit.new
				c.token = "BAR"
				git.commit_all(c)
				assert_equal c.token, git.read_token
			end
		end

    def test_read_token_encoding
      with_git_repository('git_with_invalid_encoding') do |git|
        assert_nothing_raised do
          git.read_token
        end
      end
    end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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