debian-mirror-gitlab/spec/lib/gitlab/import_sources_spec.rb

129 lines
3.7 KiB
Ruby
Raw Normal View History

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