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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/lib/gitlab/github_import/object_counter_spec.rb
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import/object_counter_spec.rb')
-rw-r--r--spec/lib/gitlab/github_import/object_counter_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/gitlab/github_import/object_counter_spec.rb b/spec/lib/gitlab/github_import/object_counter_spec.rb
new file mode 100644
index 00000000000..668c11667b5
--- /dev/null
+++ b/spec/lib/gitlab/github_import/object_counter_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GithubImport::ObjectCounter, :clean_gitlab_redis_cache do
+ let_it_be(:project) { create(:project) }
+
+ it 'validates the operation being incremented' do
+ expect { described_class.increment(project, :issue, :unknown) }
+ .to raise_error(ArgumentError, 'Operation must be fetched or imported')
+ end
+
+ it 'increments the counter and saves the key to be listed in the summary later' do
+ expect(Gitlab::Metrics)
+ .to receive(:counter)
+ .twice
+ .with(:github_importer_fetched_issue, 'The number of fetched Github Issue')
+ .and_return(double(increment: true))
+
+ expect(Gitlab::Metrics)
+ .to receive(:counter)
+ .twice
+ .with(:github_importer_imported_issue, 'The number of imported Github Issue')
+ .and_return(double(increment: true))
+
+ described_class.increment(project, :issue, :fetched)
+ described_class.increment(project, :issue, :fetched)
+ described_class.increment(project, :issue, :imported)
+ described_class.increment(project, :issue, :imported)
+
+ expect(described_class.summary(project)).to eq({
+ 'fetched' => { 'issue' => 2 },
+ 'imported' => { 'issue' => 2 }
+ })
+ end
+end