File: test_logging.rb

package info (click to toggle)
ruby-sidekiq 4.2.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,064 kB
  • ctags: 754
  • sloc: ruby: 7,384; makefile: 26; sh: 4
file content (35 lines) | stat: -rw-r--r-- 837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
require_relative 'helper'
require 'sidekiq/logging'

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

      it "has no context by default" do
        context.must_equal nil
      end

      it "can add a context" do
        Sidekiq::Logging.with_context "xx" do
          context.must_equal " xx"
        end
        context.must_equal nil
      end

      it "can use multiple contexts" do
        Sidekiq::Logging.with_context "xx" do
          context.must_equal " xx"
          Sidekiq::Logging.with_context "yy" do
            context.must_equal " xx yy"
          end
          context.must_equal " xx"
        end
        context.must_equal nil
      end
    end
  end
end