aboutsummaryrefslogtreecommitdiff
path: root/test/th_mauve_resolv.rb
blob: 98b597baeef4e873efee3a9af67fe6dd899ff9f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$:.unshift "../lib"

require 'mauve/mauve_resolv'

#
# This allows us to specify IPs for test hostnames, and also to fall back on
# regular DNS if that fails.
#

module Mauve
  class MauveResolv
    class << self
      alias_method :get_ips_for_without_testing, :get_ips_for

      def get_ips_for_with_testing(host)
        lookup = {
         "test-1.example.com" => %w(1.2.3.4 2001:1:2:3::4),
         "test-2.example.com" => %w(1.2.3.5 2001:1:2:3::5),
         "www.example.com"    => %w(1.2.3.4),
         "www2.example.com"   => %w(1.2.3.5 2001:2::2)
        }
        lookup[host] || get_ips_for_without_testing(host)
      end

      alias_method :get_ips_for, :get_ips_for_with_testing
    end
  end
end