2019-07-17 19:34:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::RuggedInstrumentation, :request_store do
|
2019-07-17 19:34:27 -04:00
|
|
|
subject { described_class }
|
|
|
|
|
|
|
|
describe '.query_time' do
|
|
|
|
it 'increments query times' do
|
2020-05-20 20:08:06 -04:00
|
|
|
subject.add_query_time(0.4510004)
|
|
|
|
subject.add_query_time(0.3220004)
|
2019-07-17 19:34:27 -04:00
|
|
|
|
2020-05-20 20:08:06 -04:00
|
|
|
expect(subject.query_time).to eq(0.773001)
|
2019-07-17 19:34:27 -04:00
|
|
|
expect(subject.query_time_ms).to eq(773.0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-06 16:08:48 -05:00
|
|
|
describe '.increment_query_count' do
|
2019-07-17 19:34:27 -04:00
|
|
|
it 'tracks query counts' do
|
|
|
|
expect(subject.query_count).to eq(0)
|
|
|
|
|
|
|
|
2.times { subject.increment_query_count }
|
|
|
|
|
|
|
|
expect(subject.query_count).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|