Sha256: 8f50fffad10fe043ab4e7867abae1081681989e180e7e5e9ae5a81e03e36c002

Contents?: true

Size: 1.15 KB

Versions: 49

Compression:

Stored size: 1.15 KB

Contents

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

49 entries across 49 versions & 1 rubygems

Version Path
logster-2.4.2 test/examples/test_sidekiq_reporter_example.rb
logster-2.4.1 test/examples/test_sidekiq_reporter_example.rb
logster-2.4.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.3.3 test/examples/test_sidekiq_reporter_example.rb
logster-2.3.2 test/examples/test_sidekiq_reporter_example.rb
logster-2.3.1 test/examples/test_sidekiq_reporter_example.rb
logster-2.3.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.2.0 test/examples/test_sidekiq_reporter_example.rb
logster-2.1.1 test/examples/test_sidekiq_reporter_example.rb
logster-1.3.1 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.11 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.9 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.8 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.7 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.6 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.5 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.4 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.3 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.2 test/examples/test_sidekiq_reporter_example.rb
logster-1.2.1 test/examples/test_sidekiq_reporter_example.rb