Commit 6ec2730f authored by Jacob Vosmaer's avatar Jacob Vosmaer

Test ProxyFlightTime middleware

parent c049534d
require 'spec_helper'
describe Gitlab::Middleware::ProxyFlightTime do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
let(:env) { {} }
let(:transaction) { double(:transaction) }
before { expect(app).to receive(:call).with(env).and_return('yay') }
describe '#call' do
it 'calls the app when metrics are disabled' do
expect(Gitlab::Metrics).to receive(:current_transaction).and_return(nil)
expect(middleware.call(env)).to eq('yay')
end
context 'when metrics are enabled' do
before { allow(Gitlab::Metrics).to receive(:current_transaction).and_return(transaction) }
it 'calls the app when metrics are enabled but no timing header is found' do
expect(middleware.call(env)).to eq('yay')
end
it 'sets proxy_flight_time and calls the app when the header is present' do
env['HTTP_GITLAB_WORHORSE_PROXY_START'] = '123'
expect(transaction).to receive(:set).with(:proxy_flight_time, an_instance_of(Float))
expect(middleware.call(env)).to eq('yay')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment