2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::ImportExport::LegacyRelationTreeSaver do
|
2019-12-26 22:10:19 +05:30
|
|
|
let(:exportable) { create(:group) }
|
|
|
|
let(:relation_tree_saver) { described_class.new }
|
|
|
|
let(:tree) { {} }
|
|
|
|
|
|
|
|
describe '#serialize' do
|
2020-06-23 00:09:42 +05:30
|
|
|
shared_examples 'FastHashSerializer with batch size' do |batch_size|
|
|
|
|
let(:serializer) { instance_double(Gitlab::ImportExport::FastHashSerializer) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it 'uses FastHashSerializer' do
|
|
|
|
expect(Gitlab::ImportExport::FastHashSerializer)
|
|
|
|
.to receive(:new)
|
|
|
|
.with(exportable, tree, batch_size: batch_size)
|
|
|
|
.and_return(serializer)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(serializer).to receive(:execute)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
relation_tree_saver.serialize(exportable, tree)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when export_reduce_relation_batch_size feature flag is enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(export_reduce_relation_batch_size: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'FastHashSerializer with batch size', Gitlab::ImportExport::JSON::StreamingSerializer::SMALLER_BATCH_SIZE
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when export_reduce_relation_batch_size feature flag is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(export_reduce_relation_batch_size: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'FastHashSerializer with batch size', Gitlab::ImportExport::JSON::StreamingSerializer::BATCH_SIZE
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|