Sha256: 469b720f883e22a2e67054c7532f6db88926b557e79fef9d53bbd2032a701d91

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 KB

Contents

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

class TestDomains < MiniTest::Unit::TestCase

  def test_delete_domain_app_not_found
    assert_raises(Heroku::API::Errors::NotFound) do
      heroku.delete_domain(random_name, 'example.com')
    end
  end

  def test_delete_domain
    with_app do |app_data|
      heroku.post_addon(app_data['name'], 'custom_domains:basic')
      heroku.post_domain(app_data['name'], 'example.com')
      response = heroku.delete_domain(app_data['name'], 'example.com')

      assert_equal(200, response.status)
      assert_equal({}, response.body)
    end
  end

  def test_delete_domains
    with_app do |app_data|
      heroku.post_addon(app_data['name'], 'custom_domains:basic')
      heroku.post_domain(app_data['name'], 'example.com')
      response = heroku.delete_domains(app_data['name'])

      assert_equal(200, response.status)
      assert_equal("", response.body)
    end
  end

  def test_get_domains
    with_app do |app_data|
      response = heroku.get_domains(app_data['name'])

      assert_equal(200, response.status)
      assert_equal([], response.body)
    end
  end

  def test_get_domains_app_not_found
    assert_raises(Heroku::API::Errors::NotFound) do
      heroku.get_domains(random_name)
    end
  end

  def test_post_domain
    with_app do |app_data|
      heroku.post_addon(app_data['name'], 'custom_domains:basic')
      response = heroku.post_domain(app_data['name'], 'example.com')

      assert_equal(201, response.status)
      assert_equal({'domain' => 'example.com'}, response.body)

      heroku.delete_domain(app_data['name'], 'example.com')
    end
  end

  def test_post_domain_addon_not_installed
    with_app do |app_data|
      assert_raises(Heroku::API::Errors::RequestFailed) do
        heroku.post_domain(app_data['name'], 'example.com')
      end
    end
  end

  def test_post_domain_app_not_found
    assert_raises(Heroku::API::Errors::NotFound) do
      heroku.post_domain(random_name, 'example.com')
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
heroku-api-0.1.7 test/test_domains.rb
heroku-api-0.1.6 test/test_domains.rb
heroku-api-0.1.5 test/test_domains.rb
heroku-api-0.1.4 test/test_domains.rb