<commit_before>require "helpers/integration_test_helper"
require "integration/factories/addresses_factory"

class TestAddresses < FogIntegrationTest
  include TestCollection

  def setup
    @subject = Fog::Compute[:google].addresses
    @factory = AddressesFactory.new(namespaced_name)

    # Example for testing collection get methods
    # Instantiating once to save time
    @example = @factory.create
  end

  def test_bad_get
    assert_nil @subject.get("bad-name", TEST_REGION)
  end

  def test_addresses_get_address_by_ip
    found = @subject.get_by_ip_address(@example.address)

    assert_equal(@example.name, found.name, "address should have same name")
    assert_equal(@example.address, found.address, "addresses should match")
  end

  def test_addresses_get_address_by_name
    found = @subject.get_by_name(@example.name)

    assert_equal(@example.name, found.name, "address should have same name")
    assert_equal(@example.address, found.address, "addresses should match")
  end

  def test_addresses_get_by_ip_address_or_name
    # Ensure we find the same addresses through both codepaths
    with_name = @subject.get_by_ip_address_or_name(@example.name)
    with_ip = @subject.get_by_ip_address_or_name(@example.address)

    assert_equal(@example.name, with_name.name, "address should have same name")
    assert_equal(@example.address, with_name.address, "addresses should match")

    assert_equal(@example.name, with_ip.name, "address should have same name")
    assert_equal(@example.address, with_ip.address, "addresses should match")
  end

  def test_addresses_in_use
    assert_equal(false, @example.in_use?, "example address should not be in use")
  end
end<commit_msg>Fixup addresses tests<commit_after>require "helpers/integration_test_helper"
require "integration/factories/addresses_factory"

class TestAddresses < FogIntegrationTest
  include TestCollection

  def setup
    @subject = Fog::Compute[:google].addresses
    @factory = AddressesFactory.new(namespaced_name)
  end

  def test_bad_get
    assert_nil @subject.get("bad-name", TEST_REGION)
  end

  def test_addresses_get_address_by_ip
    address = @factory.create
    found = @subject.get_by_ip_address(address.address)

    assert_equal(address.name, found.name, "address should have same name")
    assert_equal(address.address, found.address, "addresses should match")
  end

  def test_addresses_get_address_by_name
    address = @factory.create
    found = @subject.get_by_name(address.name)

    assert_equal(address.name, found.name, "address should have same name")
    assert_equal(address.address, found.address, "addresses should match")
  end

  def test_addresses_get_by_ip_address_or_name
    # Ensure we find the same addresses through both codepaths
    address = @factory.create
    with_name = @subject.get_by_ip_address_or_name(address.name)
    with_ip = @subject.get_by_ip_address_or_name(address.address)

    assert_equal(address.name, with_name.name, "address should have same name")
    assert_equal(address.address, with_name.address, "addresses should match")

    assert_equal(address.name, with_ip.name, "address should have same name")
    assert_equal(address.address, with_ip.address, "addresses should match")
  end

  def test_addresses_in_use
    address = @factory.create
    assert_equal(false, address.in_use?, "example address should not be in use")
  end
end
{'fraction_non_alphanumeric': 0.08510011778563015, 'fraction_numerical': 0.0, 'mean_word_length': 4.949211908931699, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3821650', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1037, 'n_words': 240}