Sha256: 639aa79c5a81406e36b628030665a4ff4f9d1340addd2bbd4870ce113ed71ce4

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../helper")

require "net/http"

class RorVsWild::Plugin::NetHttpTest < Minitest::Test
  include RorVsWildAgentHelper

  def test_callback
    agent.measure_block("test") { Net::HTTP.get("ruby-lang.org", "/index.html") }
    assert_equal(1, agent.data[:sections].size)
    assert_equal(1, agent.data[:sections][0].calls)
    assert_equal("http", agent.data[:sections][0].kind)
    assert_match("GET http://ruby-lang.org/index.html", agent.data[:sections][0].command)
  end

  def test_callback_with_https
    agent.measure_block("test") { Net::HTTP.get(URI("https://www.ruby-lang.org/index.html")) }
    assert_match("GET https://www.ruby-lang.org/index.html", agent.data[:sections][0].command)
    assert_equal("http", agent.data[:sections][0].kind)
  end

  def test_nested_query_because_net_http_request_is_recursive_when_connection_is_not_started
    agent.measure_block("test") do
      uri = URI("http://www.ruby-lang.org/index.html")
      http = Net::HTTP.new(uri.host, uri.port)
      http.request(Net::HTTP::Get.new(uri.path))
    end
    assert_equal(1, agent.data[:sections][0].calls)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rorvswild-1.2.0 test/plugin/net_http_test.rb
rorvswild-1.1.1 test/plugin/net_http_test.rb
rorvswild-1.1.0 test/plugin/net_http_test.rb
rorvswild-1.0.1 test/plugin/net_http_test.rb
rorvswild-1.0.0 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha8 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha7 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha6 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha5 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha4 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha3 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha2 test/plugin/net_http_test.rb
rorvswild-1.0.0.pre.alpha test/plugin/net_http_test.rb