Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jrothrock committed Apr 3, 2023
1 parent 6927888 commit 902f99c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/unit/instruments/net_http_test.rb
Expand Up @@ -22,6 +22,14 @@ def test_request_scout_description_for_uri
assert_equal '/here', Net::HTTP.new('').request_scout_description(req)
end

def test_instruments_http
recorder = FakeRecorder.new
ScoutApm::Agent.instance.context.recorder = recorder

Net::HTTP.get_response(URI('https://example.com'))
assert_recorded(recorder, "HTTP", "request", "example.com/")
end

def test_request_scout_description_for_addressable
req = Net::HTTP::Get.new(Addressable::URI.parse('http://example.org/here'))
assert_equal '/here', Net::HTTP.new('').request_scout_description(req)
Expand All @@ -34,4 +42,14 @@ def test_installs_using_proper_method
assert_equal false, Net::HTTP.ancestors.include?(ScoutApm::Instruments::NetHttpInstrumentationPrepend)
end
end

private

def assert_recorded(recorder, type, name, desc = nil)
req = recorder.requests.first
assert req, "recorder recorded no layers"
assert_equal type, req.root_layer.type
assert_equal name, req.root_layer.name
assert_equal desc, req.root_layer.desc if !desc.nil?
end
end

0 comments on commit 902f99c

Please sign in to comment.