debian-mirror-gitlab/spec/lib/gitlab/error_tracking/logger_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
724 B
Ruby
Raw Normal View History

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' } }
let(:log_entry) { { message: 'boom', context: payload }}
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