@@ -26,17 +26,45 @@ describe Projects::ImportService, services: true do
...
@@ -26,17 +26,45 @@ describe Projects::ImportService, services: true do
result=subject.execute
result=subject.execute
expect(result[:status]).toeq:error
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."
@@ -44,7 +72,7 @@ describe Projects::ImportService, services: true do
...
@@ -44,7 +72,7 @@ describe Projects::ImportService, services: true do
end
end
it'fails if repository import fails'do
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_any_instance_of(Gitlab::Shell).toreceive(:import_repository).and_raise(Gitlab::Shell::Error.new('Failed to import the repository'))
result=subject.execute
result=subject.execute
...
@@ -52,6 +80,7 @@ describe Projects::ImportService, services: true do
...
@@ -52,6 +80,7 @@ describe Projects::ImportService, services: true do
expect(result[:message]).toeq"Error importing repository #{project.import_url} into #{project.path_with_namespace} - Failed to import the repository"
expect(result[:message]).toeq"Error importing repository #{project.import_url} into #{project.path_with_namespace} - Failed to import the repository"
end
end
end
end
end
context'with valid importer'do
context'with valid importer'do
beforedo
beforedo
...
@@ -64,8 +93,8 @@ describe Projects::ImportService, services: true do
...
@@ -64,8 +93,8 @@ describe Projects::ImportService, services: true do
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
result=subject.execute
expect(result[:status]).toeq:error
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'))
expect_any_instance_of(Gitlab::Shell).toreceive(:fetch_remote).and_raise(Gitlab::Shell::Error.new('Failed to import the repository'))