mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 20:05:14 +08:00
DEV: Introduce stub_ip_lookup
spec helper (#20571)
This commit is contained in:
parent
f6dc6da3f8
commit
749a4c5937
|
@ -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