Sha256: f098698aba1f671382904eb45fa96a172e848f3f4acf2f28037a65b1972e4969

Contents?: true

Size: 1023 Bytes

Versions: 2

Compression:

Stored size: 1023 Bytes

Contents

require File.join(File.dirname(__FILE__), 'helper')

class TestGmanDomains < Minitest::Test
  WHITELIST = ['non-us gov', 'non-us mil', 'US Federal'].freeze

  def resolve_domains?
    ENV['GMAN_RESOLVE_DOMAINS'] == 'true'
  end

  should 'only contains valid domains' do
    importer = Gman::Importer.new({})
    if resolve_domains?
      importer.logger.info <<-MSG
        Validating that all domains resolve. This may take a while...
      MSG
    else
      importer.logger.info 'Skipping domain resolution.' \
        'Run `GMAN_RESOLVE_DOMAINS=true rake test` '\
        'to validate that domains resolve.'
    end

    invalid = []
    list = Gman::DomainList.current.list
    Parallel.each(list, in_threads: 2) do |group, domains|
      next if WHITELIST.include?(group)
      invalid.push domains.reject { |domain|
        options = { skip_dupe: true, skip_resolve: !resolve_domains? }
        importer.valid_domain?(domain, options)
      }
    end
    assert_equal [], invalid.flatten.reject(&:empty?)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gman-6.0.1 test/test_gman_domains.rb
gman-6.0.0 test/test_gman_domains.rb