Sha256: 3767232df5483c39473b2ef7e62fd0b55fdf7418317526f9c8fbcb1618b123fa

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative '../test_helper'
require 'logster/logger'
require 'logster/redis_store'
require 'logger'
require 'examples/sidekiq_logster_reporter'

class TestSidekiqReporter < MiniTest::Test

  def setup
    Logster.store = @store = Logster::RedisStore.new(Redis.new)
    Logster.logger = @logger = Logster::Logger.new(Logster.store)
    @store.clear_all
  end

  def teardown
    @store.clear_all
  end

  def test_sidekiq_handler_example
    handler = SidekiqLogsterReporter.new
    error = nil
    begin
      raise TypeError.new
    rescue => e
      error = e
    end
    trace = error.backtrace

    handler.call(error, code: "Test", something_important: "Foo", params: { article_id: 20 })

    report = @store.latest[0]

    # Message is right format
    assert_equal("Job exception: TypeError\n", report.message)

    # A backtrace is joined()
    assert_equal(trace.join("\n"), report.backtrace)
    # The backtrace is deleted from the env
    assert_nil(report.env['backtrace'])
    assert_nil(report.env[:backtrace])

    # The env is in the report
    assert_equal("Test", report.env['code'])
    assert_equal(20, report.env['params']['article_id'])
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
logster-2.12.2 test/examples/test_sidekiq_reporter_example.rb
logster-2.12.1 test/examples/test_sidekiq_reporter_example.rb
logster-2.11.4 test/examples/test_sidekiq_reporter_example.rb
logster-2.11.3 test/examples/test_sidekiq_reporter_example.rb
logster-2.11.2 test/examples/test_sidekiq_reporter_example.rb
logster-2.11.1 test/examples/test_sidekiq_reporter_example.rb
logster-2.11.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.10.1 test/examples/test_sidekiq_reporter_example.rb
logster-2.10.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.8 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.7 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.6 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.5 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.4 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.3 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.2 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.1 test/examples/test_sidekiq_reporter_example.rb
logster-2.9.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.8.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.7.1 test/examples/test_sidekiq_reporter_example.rb