Sha256: 97b9b2df45d58efd0d31a7bc99af696780c50a7c6dad19af0760dca5947d4346
Contents?: true
Size: 959 Bytes
Versions: 1
Compression:
Stored size: 959 Bytes
Contents
require_relative '../test_helper' module Appender class KafkaTest < Minitest::Test describe SemanticLogger::Appender::Kafka do before do @appender = SemanticLogger::Appender::Kafka.new( seed_brokers: ['localhost:9092'] ) @message = 'AppenderKafkaTest log message' end after do @appender&.close end it 'sends log messages in JSON format' do message = nil options = nil ::Kafka::Producer.stub_any_instance(:produce, ->(value, **opts) { message = value; options = opts }) do @appender.info(@message) @appender.flush end h = JSON.parse(message) assert_equal 'info', h['level'] assert_equal @message, h['message'] assert_equal 'SemanticLogger::Appender::Kafka', h['name'] assert_equal $PROCESS_ID, h['pid'] assert_equal 'log_messages', options[:topic] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
semantic_logger-4.2.1 | test/appender/kafka_test.rb |