2017-04-25 20:22:56 +00:00
|
|
|
module FakeBlobHelpers
|
|
|
|
class FakeBlob
|
2017-05-02 22:45:50 +00:00
|
|
|
include BlobLike
|
2017-04-25 20:22:56 +00: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
|
|
|
|
0
|
|
|
|
end
|
|
|
|
|
|
|
|
def binary?
|
|
|
|
@binary
|
|
|
|
end
|
|
|
|
|
2017-05-02 22:45:50 +00:00
|
|
|
def external_storage
|
|
|
|
:lfs if @lfs_pointer
|
2017-04-25 20:22:56 +00:00
|
|
|
end
|
|
|
|
|
2017-05-02 22:45:50 +00:00
|
|
|
alias_method :external_size, :lfs_size
|
2017-04-25 20:22:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def fake_blob(**kwargs)
|
|
|
|
Blob.decorate(FakeBlob.new(**kwargs), project)
|
|
|
|
end
|
|
|
|
end
|