@@ -26,30 +26,59 @@ describe Projects::ImportService, services: true do
result=subject.execute
expect(result[:status]).toeq:error
expect(result[:message]).toeq'The repository could not be created.'
expect(result[:message]).toeq"Error importing repository #{project.import_url} into #{project.path_with_namespace} - The repository could not be created."
expect_any_instance_of(Repository).toreceive(:fetch_remote).and_raise(Gitlab::Shell::Error.new('Failed to import the repository'))
result=subject.execute
expect(result[:status]).toeq:error
expect(result[:message]).toeq"Error importing repository #{project.import_url} into #{project.path_with_namespace} - Failed to import the repository"
end
end
it'fails if repository import fails'do
expect_any_instance_of(Gitlab::Shell).toreceive(:import_repository).with(project.repository_storage_path,project.path_with_namespace,project.import_url).and_raise(Gitlab::Shell::Error.new('Failed to import the repository'))
expect(result[:message]).toeq'The remote data could not be imported.'
expect(result[:message]).toeq"Error importing repository #{project.import_url} into #{project.path_with_namespace} - The remote data could not be imported."
expect_any_instance_of(Gitlab::GithubImport::Importer).toreceive(:execute).and_raise(Projects::ImportService::Error.new('Github: failed to connect API'))
allow_any_instance_of(Gitlab::GithubImport::Importer).toreceive(:execute).and_raise(Projects::ImportService::Error.new('Github: failed to connect API'))
result=subject.execute
expect(result[:status]).toeq:error
expect(result[:message]).toeq'Github: failed to connect API'
expect(result[:message]).toeq"Error importing repository #{project.import_url} into #{project.path_with_namespace} - Github: failed to connect API"
expect_any_instance_of(Gitlab::Shell).toreceive(:import_repository).with(project.repository_storage_path,project.path_with_namespace,project.import_url).and_raise(Gitlab::Shell::Error.new('Failed to import the repository'))