2019-11-21 04:06:16 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-08-18 05:11:27 -04:00
|
|
|
require 'fast_spec_helper'
|
2018-01-11 18:12:34 -05:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Git::LfsPointerFile do
|
2018-01-11 18:12:34 -05:00
|
|
|
let(:data) { "1234\n" }
|
|
|
|
|
|
|
|
subject { described_class.new(data) }
|
|
|
|
|
|
|
|
describe '#size' do
|
|
|
|
it 'counts the bytes' do
|
|
|
|
expect(subject.size).to eq 5
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'handles non ascii data' do
|
|
|
|
expect(described_class.new("ääää").size).to eq 8
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#sha256' do
|
|
|
|
it 'hashes the content correctly' do
|
|
|
|
expect(subject.sha256).to eq 'a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#pointer' do
|
|
|
|
it 'starts with the LFS version' do
|
|
|
|
expect(subject.pointer).to start_with('version https://git-lfs.github.com/spec/v1')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes sha256' do
|
|
|
|
expect(subject.pointer).to match(/^oid sha256:[0-9a-fA-F]{64}/)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'ends with the size' do
|
|
|
|
expect(subject.pointer).to end_with("\nsize 5\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|