blob: 9dd80e0a22978f3784d9a3ef7bdc2dbc3f69ff8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
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
if Gitlab::Database.postgresql?
"\\x#{sha}"
else
binary_sha
end
end
let(:attribute) { described_class.new }
describe '#deserialize' do
it 'converts the binary SHA to a String' do
expect(attribute.deserialize(binary_from_db)).to eq(sha)
end
end
describe '#serialize' do
it 'converts a SHA String to binary data' do
expect(attribute.serialize(sha).to_s).to eq(binary_sha)
end
end
end
|