debian-mirror-gitlab/spec/lib/gitlab/app_json_logger_spec.rb

19 lines
593 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::AppJsonLogger do
2020-03-13 15:44:24 +05:30
subject { described_class.new('/dev/null') }
let(:hash_message) { { 'message' => 'Message', 'project_id' => '123' } }
let(:string_message) { 'Information' }
it 'logs a hash as a JSON' do
2020-05-24 23:13:21 +05:30
expect(Gitlab::Json.parse(subject.format_message('INFO', Time.now, nil, hash_message))).to include(hash_message)
2020-03-13 15:44:24 +05:30
end
it 'logs a string as a JSON' do
2020-05-24 23:13:21 +05:30
expect(Gitlab::Json.parse(subject.format_message('INFO', Time.now, nil, string_message))).to include('message' => string_message)
2020-03-13 15:44:24 +05:30
end
end