mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
DEV: Introduce stub_ip_lookup
spec helper (#20571)
This commit is contained in:
parent
3f5fa4eb09
commit
b5cd22edb6
|
@ -25,15 +25,6 @@ describe FinalDestination::HTTP do
|
|||
end
|
||||
end
|
||||
|
||||
def stub_ip_lookup(stub_addr, ips)
|
||||
Addrinfo
|
||||
.stubs(:getaddrinfo)
|
||||
.with { |addr, _| addr == stub_addr }
|
||||
.returns(
|
||||
ips.map { |ip| Addrinfo.new([IPAddr.new(ip).ipv6? ? "AF_INET6" : "AF_INET", 80, nil, ip]) },
|
||||
)
|
||||
end
|
||||
|
||||
def stub_tcp_to_raise(stub_addr, exception)
|
||||
TCPSocket.stubs(:open).with { |addr| addr == stub_addr }.once.raises(exception)
|
||||
end
|
||||
|
|
|
@ -192,4 +192,13 @@ module Helpers
|
|||
|
||||
queries
|
||||
end
|
||||
|
||||
def stub_ip_lookup(stub_addr, ips)
|
||||
Addrinfo
|
||||
.stubs(:getaddrinfo)
|
||||
.with { |addr, _| addr == stub_addr }
|
||||
.returns(
|
||||
ips.map { |ip| Addrinfo.new([IPAddr.new(ip).ipv6? ? "AF_INET6" : "AF_INET", 80, nil, ip]) },
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user