2019-07-25 01:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-25 16:22:56 -04:00
|
|
|
module FakeBlobHelpers
|
|
|
|
class FakeBlob
|
2017-05-02 18:45:50 -04:00
|
|
|
include BlobLike
|
2017-04-25 16:22:56 -04:00
|
|
|
|
|
|
|
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
|
2020-04-23 05:09:46 -04:00
|
|
|
"00000000"
|
|
|
|
end
|
|
|
|
|
|
|
|
def commit_id
|
|
|
|
"11111111"
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
2018-12-13 12:49:05 -05:00
|
|
|
def binary_in_repo?
|
2017-04-25 16:22:56 -04:00
|
|
|
@binary
|
|
|
|
end
|
|
|
|
|
2017-05-02 18:45:50 -04:00
|
|
|
def external_storage
|
|
|
|
:lfs if @lfs_pointer
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
2017-05-02 18:45:50 -04:00
|
|
|
alias_method :external_size, :lfs_size
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def fake_blob(**kwargs)
|
2020-02-13 10:08:52 -05:00
|
|
|
container = kwargs.delete(:container) || project
|
|
|
|
|
|
|
|
Blob.decorate(FakeBlob.new(**kwargs), container)
|
2017-04-25 16:22:56 -04:00
|
|
|
end
|
|
|
|
end
|