2020-01-13 16:07:39 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Gitlab::AppTextLogger do
|
2020-01-13 16:07:39 -05:00
|
|
|
subject { described_class.new('/dev/null') }
|
|
|
|
|
|
|
|
let(:hash_message) { { message: 'Message', project_id: 123 } }
|
|
|
|
let(:string_message) { 'Information' }
|
|
|
|
|
|
|
|
it 'logs a hash as string' do
|
|
|
|
expect(subject.format_message('INFO', Time.now, nil, hash_message )).to include(hash_message.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'logs a string unchanged' do
|
|
|
|
expect(subject.format_message('INFO', Time.now, nil, string_message)).to include(string_message)
|
|
|
|
end
|
2020-01-14 10:07:55 -05:00
|
|
|
|
|
|
|
it 'logs time in UTC with ISO8601.3 standard' do
|
2020-08-31 11:10:41 -04:00
|
|
|
freeze_time do
|
2020-01-14 10:07:55 -05:00
|
|
|
expect(subject.format_message('INFO', Time.now, nil, string_message))
|
|
|
|
.to include(Time.now.utc.iso8601(3))
|
|
|
|
end
|
|
|
|
end
|
2020-01-13 16:07:39 -05:00
|
|
|
end
|