diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/lib/gitlab/utils/usage_data_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/utils/usage_data_spec.rb')
-rw-r--r-- | spec/lib/gitlab/utils/usage_data_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/gitlab/utils/usage_data_spec.rb b/spec/lib/gitlab/utils/usage_data_spec.rb index a74a9f06c6f..25ba5a3e09e 100644 --- a/spec/lib/gitlab/utils/usage_data_spec.rb +++ b/spec/lib/gitlab/utils/usage_data_spec.rb @@ -259,6 +259,37 @@ RSpec.describe Gitlab::Utils::UsageData do end end + describe '#average' do + let(:relation) { double(:relation) } + + it 'returns the average when operation succeeds' do + allow(Gitlab::Database::BatchCount) + .to receive(:batch_average) + .with(relation, :column, batch_size: 100, start: 2, finish: 3) + .and_return(1) + + expect(described_class.average(relation, :column, batch_size: 100, start: 2, finish: 3)).to eq(1) + end + + it 'records duration' do + expect(described_class).to receive(:with_duration) + + allow(Gitlab::Database::BatchCount).to receive(:batch_average).and_return(1) + + described_class.average(relation, :column) + end + + context 'when operation fails' do + subject { described_class.average(relation, :column) } + + let(:fallback) { 15 } + let(:failing_class) { Gitlab::Database::BatchCount } + let(:failing_method) { :batch_average } + + it_behaves_like 'failing hardening method' + end + end + describe '#histogram' do let_it_be(:projects) { create_list(:project, 3) } |