Commit c5b161d8 authored by nmilojevic1's avatar nmilojevic1

Fallback to legacy_reader in specs

- For flaky pipeline error when ff is not stubbed correctly
- Fallback to legacy reader instead creashing the test
- Check if there are no errors added to shared
parent 7fda457f
......@@ -29,14 +29,12 @@ describe Gitlab::ImportExport::Project::TreeRestorer do
stub_feature_flags(project_import_ndjson: ndjson_enabled)
setup_import_export_config('complex')
# FIXME: Disabling `setup_reader` temporarily to always fallback to legacy_relation_reader.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/213793#note_320801541
# setup_reader(reader)
setup_reader(reader)
allow_any_instance_of(Repository).to receive(:fetch_source_branch!).and_return(true)
allow_any_instance_of(Gitlab::Git::Repository).to receive(:branch_exists?).and_return(false)
expect(@shared).not_to receive(:error)
expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA')
allow_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch)
......
......@@ -36,15 +36,12 @@ module ImportExport
end
def setup_reader(reader)
case reader
when :legacy_reader
allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(true)
allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(false)
when :ndjson_reader
if reader == :ndjson_reader && Feature.enabled?(:project_import_ndjson)
allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(false)
allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(true)
else
raise "invalid reader #{reader}. Supported readers: :legacy_reader, :ndjson_reader"
allow_any_instance_of(Gitlab::ImportExport::JSON::LegacyReader::File).to receive(:exist?).and_return(true)
allow_any_instance_of(Gitlab::ImportExport::JSON::NdjsonReader).to receive(:exist?).and_return(false)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment