Welcome to mirror list, hosted at ThFree Co, Russian Federation.

diagnostic_reports_logger_spec.rb « memory « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6be528e34b608bdb271257c53cf31f21cbc9c2b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'fast_spec_helper'

RSpec.describe Gitlab::Memory::DiagnosticReportsLogger do
  subject { described_class.new('/dev/null') }

  let(:now) { Time.current }

  describe '#format_message' do
    it 'formats incoming hash properly' do
      output = subject.format_message('INFO', now, 'test', { hello: 1 })
      # Disabling the cop because it is not relevant, we encode with `JSON.generate`. Allows `fast_spec_helper`.
      data = JSON.parse(output) # rubocop: disable Gitlab/Json

      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
    end
  end
end