Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/github_import/object_counter_spec.rb')
-rw-r--r--spec/lib/gitlab/github_import/object_counter_spec.rb55
1 files changed, 54 insertions, 1 deletions
diff --git a/spec/lib/gitlab/github_import/object_counter_spec.rb b/spec/lib/gitlab/github_import/object_counter_spec.rb
index e522f74416c..92a979eddd2 100644
--- a/spec/lib/gitlab/github_import/object_counter_spec.rb
+++ b/spec/lib/gitlab/github_import/object_counter_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Gitlab::GithubImport::ObjectCounter, :clean_gitlab_redis_cache do
- let_it_be(:project) { create(:project, :import_started, import_type: 'github') }
+ let_it_be(:project) { create(:project, :import_started, import_type: 'github', import_url: 'https://github.com/vim/vim.git') }
it 'validates the operation being incremented' do
expect { described_class.increment(project, :issue, :unknown) }
@@ -57,4 +57,57 @@ RSpec.describe Gitlab::GithubImport::ObjectCounter, :clean_gitlab_redis_cache do
described_class.increment(project, :issue, :fetched)
end
+
+ describe '.summary' do
+ context 'when there are cached import statistics' do
+ before do
+ described_class.increment(project, :issue, :fetched, value: 10)
+ described_class.increment(project, :issue, :imported, value: 8)
+ end
+
+ it 'includes cached object counts stats in response' do
+ expect(described_class.summary(project)).to eq(
+ 'fetched' => { 'issue' => 10 },
+ 'imported' => { 'issue' => 8 }
+ )
+ end
+ end
+
+ context 'when there are no cached import statistics' do
+ context 'when project import is in progress' do
+ it 'includes an empty object counts stats in response' do
+ expect(described_class.summary(project)).to eq(described_class::EMPTY_SUMMARY)
+ end
+ end
+
+ context 'when project import is not in progress' do
+ let(:checksums) do
+ {
+ 'fetched' => {
+ "issue" => 2,
+ "label" => 10,
+ "note" => 2,
+ "protected_branch" => 2,
+ "pull_request" => 2
+ },
+ "imported" => {
+ "issue" => 2,
+ "label" => 10,
+ "note" => 2,
+ "protected_branch" => 2,
+ "pull_request" => 2
+ }
+ }
+ end
+
+ before do
+ project.import_state.update_columns(checksums: checksums, status: :finished)
+ end
+
+ it 'includes project import checksums in response' do
+ expect(described_class.summary(project)).to eq(checksums)
+ end
+ end
+ end
+ end
end