debian-mirror-gitlab/spec/support/helpers/fake_blob_helpers.rb

45 lines
831 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module FakeBlobHelpers
class FakeBlob
include BlobLike
attr_reader :path, :size, :data, :lfs_oid, :lfs_size
def initialize(path: 'file.txt', size: 1.kilobyte, data: 'foo', binary: false, lfs: nil)
@path = path
@size = size
@data = data
@binary = binary
@lfs_pointer = lfs.present?
if @lfs_pointer
@lfs_oid = SecureRandom.hex(20)
@lfs_size = 1.megabyte
end
end
alias_method :name, :path
def id
0
end
2019-02-15 15:39:39 +05:30
def binary_in_repo?
2017-08-17 22:00:37 +05:30
@binary
end
def external_storage
:lfs if @lfs_pointer
end
alias_method :external_size, :lfs_size
end
def fake_blob(**kwargs)
2020-03-09 13:42:32 +05:30
container = kwargs.delete(:container) || project
Blob.decorate(FakeBlob.new(**kwargs), container)
2017-08-17 22:00:37 +05:30
end
end