forked from eventmachine/eventmachine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_resolver.rb
55 lines (49 loc) · 1.02 KB
/
test_resolver.rb
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'em_test_helper'
class TestResolver < Test::Unit::TestCase
def test_a
EM.run {
d = EM::DNS::Resolver.resolve "google.com"
d.errback { assert false }
d.callback { |r|
assert r
EM.stop
}
}
end
def test_bad_host
EM.run {
d = EM::DNS::Resolver.resolve "asdfasasdf"
d.callback { assert false }
d.errback { assert true; EM.stop }
}
end
def test_garbage
assert_raises( ArgumentError ) {
EM.run {
EM::DNS::Resolver.resolve 123
}
}
end
def test_a_pair
EM.run {
d = EM::DNS::Resolver.resolve "google.com"
d.errback { assert false }
d.callback { |r|
assert_equal(Array, r.class)
assert r.size > 1
EM.stop
}
}
end
def test_localhost
EM.run {
d = EM::DNS::Resolver.resolve "localhost"
d.errback { assert false }
d.callback { |r|
assert_equal("127.0.0.1", r.first)
assert_equal(Array, r.class)
EM.stop
}
}
end
end