Sha256: 8f650160af25e88073f1c6ba6da0a45c5d7c412cf60b0fd42104e94096df6178

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require "test_helper"
require 'base64'

context "Rugged::Lib stuff" do
  setup do
  end

  test "can convert hex into raw oid" do
    raw = Rugged::hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
    b64raw = Base64.encode64(raw).strip
    assert_equal "zgj+SIRlDwZ71XA7almos7PJmgk=", b64raw
  end

  test "converts hex into raw oid correctly" do
    hex = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09"
    raw1 = Rugged::hex_to_raw(hex)
    raw2 = [hex].pack("H*")
    assert_equal raw1, raw2
  end

  test "can convert raw oid into hex" do
    raw = Base64.decode64("FqASNFZ4mrze9Ld1ITwjqL109eA=")
    hex = Rugged::raw_to_hex(raw)
    assert_equal "16a0123456789abcdef4b775213c23a8bd74f5e0", hex
  end

  test "converts raw into hex oid correctly" do
    raw = Rugged::hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
    hex1 = Rugged::raw_to_hex(raw)
    hex2 = raw.unpack("H*")[0]
    assert_equal hex1, hex2
  end

  test "converts raw into hex with null bytes" do
    raw = Rugged::hex_to_raw("702f00394564b24052511cb69961164828bf5494")
    hex1 = Rugged::raw_to_hex(raw)
    hex2 = raw.unpack("H*")[0]
    assert_equal hex1, hex2
  end

  test "prettifies commit messages properly" do
    message = <<-MESSAGE
Testing this whole prettify business    

with newlines and stuff  
# take out this line haha
# and this one

not this one    
MESSAGE
  
    clean_message = <<-MESSAGE
Testing this whole prettify business

with newlines and stuff

not this one
MESSAGE

    assert_equal clean_message, Rugged::prettify_message(message, true)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rugged-0.17.0.b7 test/lib_test.rb