2019-11-07 22:06:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-16 03:15:30 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::ImportSources do
|
2016-12-16 03:15:30 -05:00
|
|
|
describe '.options' do
|
|
|
|
it 'returns a hash' do
|
|
|
|
expected =
|
|
|
|
{
|
2018-07-18 00:14:11 -04:00
|
|
|
'GitHub' => 'github',
|
|
|
|
'Bitbucket Cloud' => 'bitbucket',
|
|
|
|
'Bitbucket Server' => 'bitbucket_server',
|
|
|
|
'GitLab.com' => 'gitlab',
|
|
|
|
'Google Code' => 'google_code',
|
|
|
|
'FogBugz' => 'fogbugz',
|
|
|
|
'Repo by URL' => 'git',
|
|
|
|
'GitLab export' => 'gitlab_project',
|
|
|
|
'Gitea' => 'gitea',
|
2019-04-23 10:27:01 -04:00
|
|
|
'Manifest file' => 'manifest',
|
|
|
|
'Phabricator' => 'phabricator'
|
2016-12-16 03:15:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
expect(described_class.options).to eq(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.values' do
|
|
|
|
it 'returns an array' do
|
|
|
|
expected =
|
2017-02-22 12:46:57 -05:00
|
|
|
%w(
|
2017-02-22 13:03:32 -05:00
|
|
|
github
|
|
|
|
bitbucket
|
2018-07-18 00:14:11 -04:00
|
|
|
bitbucket_server
|
2017-02-22 13:03:32 -05:00
|
|
|
gitlab
|
|
|
|
google_code
|
|
|
|
fogbugz
|
|
|
|
git
|
|
|
|
gitlab_project
|
|
|
|
gitea
|
2018-07-05 05:54:46 -04:00
|
|
|
manifest
|
2019-04-23 10:27:01 -04:00
|
|
|
phabricator
|
2017-02-22 13:03:32 -05:00
|
|
|
)
|
2016-12-16 03:15:30 -05: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 12:46:57 -05:00
|
|
|
%w(
|
2017-02-22 13:03:32 -05:00
|
|
|
github
|
|
|
|
bitbucket
|
2018-07-18 00:14:11 -04:00
|
|
|
bitbucket_server
|
2017-02-22 13:03:32 -05:00
|
|
|
gitlab
|
|
|
|
google_code
|
|
|
|
fogbugz
|
|
|
|
gitlab_project
|
|
|
|
gitea
|
2019-04-23 10:27:01 -04:00
|
|
|
phabricator
|
2017-02-22 13:03:32 -05:00
|
|
|
)
|
2016-12-16 03:15:30 -05:00
|
|
|
|
|
|
|
expect(described_class.importer_names).to eq(expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.importer' do
|
|
|
|
import_sources = {
|
2017-10-18 15:46:05 -04:00
|
|
|
'github' => Gitlab::GithubImport::ParallelImporter,
|
2016-12-16 03:15:30 -05:00
|
|
|
'bitbucket' => Gitlab::BitbucketImport::Importer,
|
2018-07-18 00:14:11 -04:00
|
|
|
'bitbucket_server' => Gitlab::BitbucketServerImport::Importer,
|
2016-12-16 03:15:30 -05:00
|
|
|
'gitlab' => Gitlab::GitlabImport::Importer,
|
|
|
|
'google_code' => Gitlab::GoogleCodeImport::Importer,
|
|
|
|
'fogbugz' => Gitlab::FogbugzImport::Importer,
|
|
|
|
'git' => nil,
|
|
|
|
'gitlab_project' => Gitlab::ImportExport::Importer,
|
2018-07-05 05:54:46 -04:00
|
|
|
'gitea' => Gitlab::LegacyGithubImport::Importer,
|
2019-04-23 10:27:01 -04:00
|
|
|
'manifest' => nil,
|
|
|
|
'phabricator' => Gitlab::PhabricatorImport::Importer
|
2016-12-16 03:15:30 -05: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 00:14:11 -04:00
|
|
|
'bitbucket' => 'Bitbucket Cloud',
|
|
|
|
'bitbucket_server' => 'Bitbucket Server',
|
2016-12-16 03:15:30 -05:00
|
|
|
'gitlab' => 'GitLab.com',
|
|
|
|
'google_code' => 'Google Code',
|
|
|
|
'fogbugz' => 'FogBugz',
|
|
|
|
'git' => 'Repo by URL',
|
|
|
|
'gitlab_project' => 'GitLab export',
|
2018-07-05 05:54:46 -04:00
|
|
|
'gitea' => 'Gitea',
|
2019-04-23 10:27:01 -04:00
|
|
|
'manifest' => 'Manifest file',
|
|
|
|
'phabricator' => 'Phabricator'
|
2016-12-16 03:15:30 -05: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 12:42:18 -04:00
|
|
|
|
|
|
|
describe 'imports_repository? checker' do
|
2019-04-23 10:27:01 -04:00
|
|
|
let(:allowed_importers) { %w[github gitlab_project bitbucket_server phabricator] }
|
2018-06-06 12:42:18 -04: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 03:15:30 -05:00
|
|
|
end
|