summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-11 18:26:49 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-11 18:26:49 +0000
commit9e677261a9147616c32bb32004fcf99e868563d7 (patch)
tree124e312cac136adaa10e5d85b34f4ebf3805f524 /test
parentddb799637200af5efa861021b003ab06ef71d973 (diff)
Mock fetching data from real DNS [Feature #14340]
This test just tests MDNS#each_address method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/resolv/test_mdns.rb28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/resolv/test_mdns.rb b/test/resolv/test_mdns.rb
index 8e401883f1..9c17f9b219 100644
--- a/test/resolv/test_mdns.rb
+++ b/test/resolv/test_mdns.rb
@@ -3,20 +3,24 @@ require 'test/unit'
require 'resolv'
class TestResolvMDNS < Test::Unit::TestCase
- def setup
- end
-
def test_mdns_each_address
- begin
- mdns = Resolv::MDNS.new
- mdns.each_resource '_http._tcp.local', Resolv::DNS::Resource::IN::PTR do |r|
- srv = mdns.getresource r.name, Resolv::DNS::Resource::IN::SRV
- mdns.each_address(srv.target) do |result|
- assert_not_nil(result)
- end
+ mdns = Resolv::MDNS.new
+ def mdns.each_resource(name, typeclass)
+ if typeclass == Resolv::DNS::Resource::IN::A
+ yield typeclass.new("127.0.0.1")
+ else
+ yield typeclass.new("::1")
+ end
+ end
+ [
+ ["example.com", []],
+ ["foo.local", ["127.0.0.1"]],
+ ].each do |name, expect|
+ results = []
+ mdns.each_address(name) do |result|
+ results << result.to_s
end
- rescue Errno::EADDRNOTAVAIL
- # Handle Raspberry Pi environment.
+ assert_equal expect, results, "GH-1484"
end
end
end