debian-mirror-gitlab/spec/lib/gitlab/database/sha_attribute_spec.rb

32 lines
619 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
describe Gitlab::Database::ShaAttribute do
let(:sha) do
'9a573a369a5bfbb9a4a36e98852c21af8a44ea8b'
end
let(:binary_sha) do
[sha].pack('H*')
end
let(:binary_from_db) do
2019-10-12 21:52:04 +05:30
"\\x#{sha}"
2017-09-10 17:25:29 +05:30
end
let(:attribute) { described_class.new }
2018-05-09 12:01:36 +05:30
describe '#deserialize' do
2017-09-10 17:25:29 +05:30
it 'converts the binary SHA to a String' do
2018-05-09 12:01:36 +05:30
expect(attribute.deserialize(binary_from_db)).to eq(sha)
2017-09-10 17:25:29 +05:30
end
end
2018-05-09 12:01:36 +05:30
describe '#serialize' do
2017-09-10 17:25:29 +05:30
it 'converts a SHA String to binary data' do
2018-05-09 12:01:36 +05:30
expect(attribute.serialize(sha).to_s).to eq(binary_sha)
2017-09-10 17:25:29 +05:30
end
end
end