diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 06:07:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 06:07:58 +0300 |
commit | 1eeef229aae5affdce415c2364858e8efc64f4b5 (patch) | |
tree | 7bbd126a3b41c4c8855a8e84ece3972030177acb /spec/lib/gitlab/import | |
parent | 5d32a7a175fd1a7a6c97019a022c11434ea637dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/import')
-rw-r--r-- | spec/lib/gitlab/import/metrics_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import/metrics_spec.rb b/spec/lib/gitlab/import/metrics_spec.rb new file mode 100644 index 00000000000..0799d19fcef --- /dev/null +++ b/spec/lib/gitlab/import/metrics_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Import::Metrics do + let(:importer_stub) do + Class.new do + prepend Gitlab::Import::Metrics + + Gitlab::Import::Metrics.measure :execute, metrics: { + importer_counter: { + type: :counter, + description: 'description' + }, + importer_histogram: { + type: :histogram, + labels: { importer: 'importer' }, + description: 'description' + } + } + + def execute + true + end + end + end + + subject { importer_stub.new.execute } + + describe '#execute' do + let(:counter) { double(:counter) } + let(:histogram) { double(:histogram) } + + it 'increments counter metric' do + expect(Gitlab::Metrics) + .to receive(:counter) + .with(:importer_counter, 'description') + .and_return(counter) + + expect(counter).to receive(:increment) + + subject + end + + it 'measures method duration and reports histogram metric' do + expect(Gitlab::Metrics) + .to receive(:histogram) + .with(:importer_histogram, 'description') + .and_return(histogram) + + expect(histogram).to receive(:observe).with({ importer: 'importer' }, anything) + + subject + end + end +end |