2022-07-23 23:45:48 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Gitlab::ErrorTracking::Logger do
|
|
|
|
describe '.capture_exception' do
|
|
|
|
let(:exception) { RuntimeError.new('boom') }
|
|
|
|
let(:payload) { { foo: '123' } }
|
2022-08-27 11:52:29 +05:30
|
|
|
let(:log_entry) { { message: 'boom', context: payload } }
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
it 'calls Gitlab::ErrorTracking::Logger.error with formatted log entry' do
|
|
|
|
expect_next_instance_of(Gitlab::ErrorTracking::LogFormatter) do |log_formatter|
|
|
|
|
expect(log_formatter).to receive(:generate_log).with(exception, payload).and_return(log_entry)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(Gitlab::ErrorTracking::Logger).to receive(:error).with(log_entry)
|
|
|
|
|
|
|
|
described_class.capture_exception(exception, **payload)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|