Improve the gitea importer test
The changes to the tests to support ignoring Gitea pull requests comments were a bit of a hack. The suggestions provided by Ash McKenzie in gitlab-org/gitlab-ce!29521 make things a bit more flexible if any future changes need to be made to the tests. The changes made to ignore
This commit is contained in:
parent
e47d9b3d04
commit
265e52bb80
|
@ -13,27 +13,22 @@ describe Gitlab::LegacyGithubImport::Importer do
|
||||||
|
|
||||||
expected_called = [
|
expected_called = [
|
||||||
:import_labels, :import_milestones, :import_pull_requests, :import_issues,
|
:import_labels, :import_milestones, :import_pull_requests, :import_issues,
|
||||||
:import_wiki, :import_releases, :handle_errors
|
:import_wiki, :import_releases, :handle_errors,
|
||||||
|
[:import_comments, :issues],
|
||||||
|
[:import_comments, :pull_requests]
|
||||||
]
|
]
|
||||||
|
|
||||||
expected_called -= expected_not_called
|
expected_called -= expected_not_called
|
||||||
|
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
expected_called.each do |method_name|
|
expected_called.each do |method_name, arg|
|
||||||
expect(importer).to receive(method_name)
|
base_expectation = proc { expect(importer).to receive(method_name) }
|
||||||
|
arg ? base_expectation.call.with(arg) : base_expectation.call
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(importer).to receive(:import_comments).with(:issues)
|
expected_not_called.each do |method_name, arg|
|
||||||
|
base_expectation = proc { expect(importer).not_to receive(method_name) }
|
||||||
if expected_not_called.include? :import_comments_pull_requests
|
arg ? base_expectation.call.with(arg) : base_expectation.call
|
||||||
expect(importer).not_to receive(:import_comments).with(:pull_requests)
|
|
||||||
expected_not_called.delete_at expected_not_called.index :import_comments_pull_requests
|
|
||||||
else
|
|
||||||
expect(importer).to receive(:import_comments).with(:pull_requests)
|
|
||||||
end
|
|
||||||
|
|
||||||
expected_not_called.each do |method_name|
|
|
||||||
expect(importer).not_to receive(method_name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -295,7 +290,7 @@ describe Gitlab::LegacyGithubImport::Importer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute' do
|
it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute' do
|
||||||
let(:expected_not_called) { [:import_releases, :import_comments_pull_requests] }
|
let(:expected_not_called) { [:import_releases, [:import_comments, :pull_requests]] }
|
||||||
end
|
end
|
||||||
it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute an error occurs'
|
it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute an error occurs'
|
||||||
it_behaves_like 'Gitlab::LegacyGithubImport unit-testing'
|
it_behaves_like 'Gitlab::LegacyGithubImport unit-testing'
|
||||||
|
|
Loading…
Reference in New Issue