diff options
Diffstat (limited to 'spec/lib/gitlab/json_logger_spec.rb')
-rw-r--r-- | spec/lib/gitlab/json_logger_spec.rb | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb index 801de357ddc..87df20c066b 100644 --- a/spec/lib/gitlab/json_logger_spec.rb +++ b/spec/lib/gitlab/json_logger_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::JsonLogger do subject { described_class.new('/dev/null') } - let(:now) { Time.now } + it_behaves_like 'a json logger', {} describe '#file_name' do let(:subclass) do @@ -26,31 +26,4 @@ RSpec.describe Gitlab::JsonLogger do expect(subclass.file_name).to eq('testlogger.log') end end - - describe '#format_message' do - before do - allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('new-correlation-id') - end - - it 'formats strings' do - output = subject.format_message('INFO', now, 'test', 'Hello world') - data = Gitlab::Json.parse(output) - - expect(data['severity']).to eq('INFO') - expect(data['time']).to eq(now.utc.iso8601(3)) - expect(data['message']).to eq('Hello world') - expect(data['correlation_id']).to eq('new-correlation-id') - end - - it 'formats hashes' do - output = subject.format_message('INFO', now, 'test', { hello: 1 }) - data = Gitlab::Json.parse(output) - - expect(data['severity']).to eq('INFO') - expect(data['time']).to eq(now.utc.iso8601(3)) - expect(data['hello']).to eq(1) - expect(data['message']).to be_nil - expect(data['correlation_id']).to eq('new-correlation-id') - end - end end |