Sha256: f55db50f6bff1809a36c86edc975c49ba24b73d7bc741683a2e5a54ee0b645f2

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

require 'test_helper'

class CheckerTest < MiniTest::Unit::TestCase
  TEST_URL = 'http://localhost:3000/options/full_stack_status'

  def test_maintenance
    stub_request(:get, TEST_URL)
      .to_return(body: 'Maintenance', status: 503)

    res = ShuntCache::Checker.wait_for_http(TEST_URL, {
      wait_time: 0
    })
    assert_equal false, res
  end

  def test_connection_issues
    stub_request(:get, TEST_URL)
      .to_raise(Errno::ECONNREFUSED)

    res = ShuntCache::Checker.wait_for_http(TEST_URL, {
      wait_time: 0
    })
    assert_equal false, res
  end

  def test_should_retry
    stub_request(:get, TEST_URL)
      .to_raise(Errno::ECONNREFUSED).then
      .to_return(body: 'OK')

    res = ShuntCache::Checker.wait_for_http(TEST_URL, {
      wait_time: 0
    })
    assert_equal true, res
  end

  def test_success
    stub_request(:get, TEST_URL)
      .to_return(body: 'OK')

    res = ShuntCache::Checker.wait_for_http(TEST_URL)
    assert_equal true, res
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shunt_cache-0.1.0 test/checker_test.rb
shunt_cache-0.0.2 test/checker_test.rb