Sha256: 5178e0ca30b0b24f601a83bff5d4a5581bcb9c2f12c128796736e86bc9a6c8b9

Contents?: true

Size: 805 Bytes

Versions: 3

Compression:

Stored size: 805 Bytes

Contents

# frozen_string_literal: true
require_relative 'helper'
require 'sidekiq/logging'

class TestLogging < Sidekiq::Test
  describe Sidekiq::Logging do
    describe "#with_context" do
      def ctx
        Sidekiq::Logging.logger.formatter.context
      end

      it "has no context by default" do
        assert_nil ctx
      end

      it "can add a context" do
        Sidekiq::Logging.with_context "xx" do
          assert_equal " xx", ctx
        end
        assert_nil ctx
      end

      it "can use multiple contexts" do
        Sidekiq::Logging.with_context "xx" do
          assert_equal " xx", ctx
          Sidekiq::Logging.with_context "yy" do
            assert_equal " xx yy", ctx
          end
          assert_equal " xx", ctx
        end
        assert_nil ctx
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-5.0.0.beta1 test/test_logging.rb
sidekiq-4.2.9 test/test_logging.rb
sidekiq-4.2.8 test/test_logging.rb