2019-11-08 03:06:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-16 08:15:30 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 18:09:03 +00:00
|
|
|
RSpec.describe Gitlab::ImportSources do
|
2016-12-16 08:15:30 +00:00
|
|
|
describe '.options' do
|
|
|
|
it 'returns a hash' do
|
|
|
|
expected =
|
|
|
|
{
|
2022-05-31 12:09:12 +00:00
|
|
|
'GitHub' => 'github',
|
|
|
|
'Bitbucket Cloud' => 'bitbucket',
|
|
|
|
'Bitbucket Server' => 'bitbucket_server',
|
|
|
|
'GitLab.com' => 'gitlab',
|
|
|
|
'Google Code' => 'google_code',
|
|
|
|
'FogBugz' => 'fogbugz',
|
|
|
|
'Repository by URL' => 'git',
|
|
|
|
'GitLab export' => 'gitlab_project',
|
|
|
|
'Gitea' => 'gitea',
|
|
|
|
'Manifest file' => 'manifest',
|
|
|
|
'Phabricator' => 'phabricator'
|
2016-12-16 08:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
expect(described_class.options).to eq(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.values' do
|
|
|
|
it 'returns an array' do
|
|
|
|
expected =
|
2017-02-22 17:46:57 +00:00
|
|
|
%w(
|
2017-02-22 18:03:32 +00:00
|
|
|
github
|
|
|
|
bitbucket
|
2018-07-18 04:14:11 +00:00
|
|
|
bitbucket_server
|
2017-02-22 18:03:32 +00:00
|
|
|
gitlab
|
2020-11-27 06:09:47 +00:00
|
|
|
google_code
|
2017-02-22 18:03:32 +00:00
|
|
|
fogbugz
|
|
|
|
git
|
|
|
|
gitlab_project
|
|
|
|
gitea
|
2018-07-05 09:54:46 +00:00
|
|
|
manifest
|
2019-04-23 14:27:01 +00:00
|
|
|
phabricator
|
2017-02-22 18:03:32 +00:00
|
|
|
)
|
2016-12-16 08:15:30 +00:00
|
|
|
|
|
|
|
expect(described_class.values).to eq(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.importer_names' do
|
|
|
|
it 'returns an array of importer names' do
|
|
|
|
expected =
|
2017-02-22 17:46:57 +00:00
|
|
|
%w(
|
2017-02-22 18:03:32 +00:00
|
|
|
github
|
|
|
|
bitbucket
|
2018-07-18 04:14:11 +00:00
|
|
|
bitbucket_server
|
2017-02-22 18:03:32 +00:00
|
|
|
gitlab
|
|
|
|
fogbugz
|
|
|
|
gitlab_project
|
|
|
|
gitea
|
2019-04-23 14:27:01 +00:00
|
|
|
phabricator
|
2017-02-22 18:03:32 +00:00
|
|
|
)
|
2016-12-16 08:15:30 +00:00
|
|
|
|
|
|
|
expect(described_class.importer_names).to eq(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.importer' do
|
|
|
|
import_sources = {
|
2017-10-18 19:46:05 +00:00
|
|
|
'github' => Gitlab::GithubImport::ParallelImporter,
|
2016-12-16 08:15:30 +00:00
|
|
|
'bitbucket' => Gitlab::BitbucketImport::Importer,
|
2018-07-18 04:14:11 +00:00
|
|
|
'bitbucket_server' => Gitlab::BitbucketServerImport::Importer,
|
2016-12-16 08:15:30 +00:00
|
|
|
'gitlab' => Gitlab::GitlabImport::Importer,
|
2020-11-27 06:09:47 +00:00
|
|
|
'google_code' => nil,
|
2016-12-16 08:15:30 +00:00
|
|
|
'fogbugz' => Gitlab::FogbugzImport::Importer,
|
|
|
|
'git' => nil,
|
|
|
|
'gitlab_project' => Gitlab::ImportExport::Importer,
|
2018-07-05 09:54:46 +00:00
|
|
|
'gitea' => Gitlab::LegacyGithubImport::Importer,
|
2019-04-23 14:27:01 +00:00
|
|
|
'manifest' => nil,
|
|
|
|
'phabricator' => Gitlab::PhabricatorImport::Importer
|
2016-12-16 08:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
import_sources.each do |name, klass|
|
|
|
|
it "returns #{klass} when given #{name}" do
|
|
|
|
expect(described_class.importer(name)).to eq(klass)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.title' do
|
|
|
|
import_sources = {
|
|
|
|
'github' => 'GitHub',
|
2018-07-18 04:14:11 +00:00
|
|
|
'bitbucket' => 'Bitbucket Cloud',
|
|
|
|
'bitbucket_server' => 'Bitbucket Server',
|
2016-12-16 08:15:30 +00:00
|
|
|
'gitlab' => 'GitLab.com',
|
2020-11-27 06:09:47 +00:00
|
|
|
'google_code' => 'Google Code',
|
2016-12-16 08:15:30 +00:00
|
|
|
'fogbugz' => 'FogBugz',
|
2022-05-31 12:09:12 +00:00
|
|
|
'git' => 'Repository by URL',
|
2016-12-16 08:15:30 +00:00
|
|
|
'gitlab_project' => 'GitLab export',
|
2018-07-05 09:54:46 +00:00
|
|
|
'gitea' => 'Gitea',
|
2019-04-23 14:27:01 +00:00
|
|
|
'manifest' => 'Manifest file',
|
|
|
|
'phabricator' => 'Phabricator'
|
2016-12-16 08:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
import_sources.each do |name, title|
|
|
|
|
it "returns #{title} when given #{name}" do
|
|
|
|
expect(described_class.title(name)).to eq(title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-06-06 16:42:18 +00:00
|
|
|
|
|
|
|
describe 'imports_repository? checker' do
|
2019-04-23 14:27:01 +00:00
|
|
|
let(:allowed_importers) { %w[github gitlab_project bitbucket_server phabricator] }
|
2018-06-06 16:42:18 +00:00
|
|
|
|
|
|
|
it 'fails if any importer other than the allowed ones implements this method' do
|
|
|
|
current_importers = described_class.values.select { |kind| described_class.importer(kind).try(:imports_repository?) }
|
|
|
|
not_allowed_importers = current_importers - allowed_importers
|
|
|
|
|
|
|
|
expect(not_allowed_importers).to be_empty, failure_message(not_allowed_importers)
|
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message(importers_class_names)
|
|
|
|
<<-MSG
|
|
|
|
It looks like the #{importers_class_names.join(', ')} importers implements its own way to import the repository.
|
|
|
|
That means that the lfs object download must be handled for each of them. You can use 'LfsImportService' and
|
|
|
|
'LfsDownloadService' to implement it. After that, add the importer name to the list of allowed importers in this spec.
|
|
|
|
MSG
|
|
|
|
end
|
|
|
|
end
|
2016-12-16 08:15:30 +00:00
|
|
|
end
|