Sha256: 211971eb25621ec9b75d1ff0ecadb4a79b9bc4de1f1244f5e55d622403264905

Contents?: true

Size: 1.07 KB

Versions: 56

Compression:

Stored size: 1.07 KB

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

require 'test_helper'

class RequestClientTest < Minitest::Test
  def test_send_request_simple
    stub_request(:get, 'http://example.com:9292/')
      .to_return(body: 'ok', status: '200')

    subject = Instana::Backend::RequestClient.new('example.com', 9292)
    response = subject.send_request('GET', '/')

    assert response.ok?
    assert 'ok', response.body
  end

  def test_send_request_json
    stub_request(:post, 'http://example.com:9292/')
      .with(body: '{"key":"value"}')
      .to_return(body: '{"ok": true}', status: '200')

    subject = Instana::Backend::RequestClient.new('example.com', 9292)
    response = subject.send_request('POST', '/', {key: 'value'})

    assert response.ok?
    assert_equal({"ok" => true}, response.json)
  end

  def test_send_request_failure
    stub_request(:get, 'http://example.com:9292/')
      .to_return(status: '500')

    subject = Instana::Backend::RequestClient.new('example.com', 9292)
    response = subject.send_request('GET', '/')

    refute response.ok?
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
instana-1.217.1 test/backend/request_client_test.rb
instana-1.217.0 test/backend/request_client_test.rb
instana-1.216.0 test/backend/request_client_test.rb
instana-1.215.1 test/backend/request_client_test.rb
instana-1.215.0 test/backend/request_client_test.rb
instana-1.214.4 test/backend/request_client_test.rb
instana-1.214.3 test/backend/request_client_test.rb
instana-1.214.2 test/backend/request_client_test.rb
instana-1.214.1 test/backend/request_client_test.rb
instana-1.214.0 test/backend/request_client_test.rb
instana-1.213.3 test/backend/request_client_test.rb
instana-1.213.2 test/backend/request_client_test.rb
instana-1.213.1 test/backend/request_client_test.rb
instana-1.213.0 test/backend/request_client_test.rb
instana-1.212.0 test/backend/request_client_test.rb
instana-1.211.0 test/backend/request_client_test.rb
instana-1.210.1 test/backend/request_client_test.rb
instana-1.210.0 test/backend/request_client_test.rb
instana-1.209.8 test/backend/request_client_test.rb
instana-1.209.7 test/backend/request_client_test.rb