Skip to content

Commit

Permalink
test: Update ActiveSupportLogger tests
Browse files Browse the repository at this point in the history
Test the outcome rather than the presence of variables
  • Loading branch information
kaylareopelle committed Dec 6, 2024
1 parent eda40db commit d7ea817
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@
after { instrumentation.instance_variable_set(:@installed, false) }

describe '#broadcast' do
it 'emits the log to the Rails.logger' do
it 'streams the log to the Rails.logger' do
msg = "spruce #{rand(6)}"
Rails.logger.debug(msg)

assert_match(/#{msg}/, LOG_STREAM.string)
end

it 'emits the broadcasted log' do
it 'streams the broadcasted log' do
msg = "willow #{rand(6)}"
Rails.logger.debug(msg)

assert_match(/#{msg}/, BROADCASTED_STREAM.string)
end

it 'records the log record' do
it 'emits the log record' do
msg = "hemlock #{rand(6)}"
Rails.logger.debug(msg)
log_record = EXPORTER.emitted_log_records.first

assert_match(/#{msg}/, log_record.body)
end

it 'does not add @skip_otel_emit to the initial logger' do
refute Rails.logger.instance_variable_defined?(:@skip_otel_emit)
end
it 'emits the log record only once' do
msg = "juniper #{rand(6)}"
Rails.logger.debug(msg)

it 'adds @skip_otel_emit to broadcasted loggers' do
assert broadcasted_logger.instance_variable_defined?(:@skip_otel_emit)
assert_equal 1, EXPORTER.emitted_log_records.size
assert_match(/#{msg}/, log_record.body)
end
end
end

0 comments on commit d7ea817

Please sign in to comment.