Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unused variable warnings in unit tests #2552

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/new_relic/agent/llm/feedback_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_record_llm_feedback_event_records_optional_attributes
NewRelic::Agent.record_llm_feedback_event(trace_id: @trace_id, rating: 5,
category: 'Helpful', message: 'Looks good!', metadata: {'pop' => 'tart', 'toaster' => 'strudel'})
_, events = NewRelic::Agent.agent.custom_event_aggregator.harvest!
type, attributes = events[0]
_, attributes = events[0]

assert_equal 'Helpful', attributes['category']
assert_equal 'Looks good!', attributes['message']
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_record_llm_feedback_event_requires_distributed_tracing
in_transaction do
NewRelic::Agent.record_llm_feedback_event(trace_id: @trace_id, rating: 5)
_, events = NewRelic::Agent.agent.custom_event_aggregator.harvest!
type, attributes = events[0]
_, attributes = events[0]

assert_nil attributes
end
Expand Down
2 changes: 1 addition & 1 deletion test/new_relic/agent/serverless_handler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def test_custom_attributes_arent_supported_when_serverless
skip_unless_minitest5_or_above

attrs = {cool_id: 'James', server: 'less', current_time: Time.now.to_s}
attribute_set_attempted = false
tl_current_mock = Minitest::Mock.new
tl_current_mock.expect :add_custom_attributes, -> { attribute_set_attempted = true }, [attrs]
Comment on lines +279 to 281
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning for this one said attribute_set_attempted was assigned, but never used, with the mock.expect line as the culprit. Defining the argument before the proc removed the warning.


attribute_set_attempted = false
in_transaction do
Transaction.stub :tl_current, tl_current_mock do
::NewRelic::Agent.add_custom_attributes(attrs)
Expand Down