Tests should not rely on external services (#6703)
This test depends on example.com site to be reachable, and fails when there is no internet connection.
This commit is contained in:
parent
253ae4e25e
commit
b7ea1b0819
1 changed files with 13 additions and 2 deletions
|
|
@ -3,11 +3,22 @@ discard """
|
||||||
output: "Finished"
|
output: "Finished"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncdispatch
|
import asyncdispatch, asyncnet
|
||||||
|
|
||||||
|
proc createServer(port: Port) {.async.} =
|
||||||
|
var server = newAsyncSocket()
|
||||||
|
server.setSockOpt(OptReuseAddr, true)
|
||||||
|
bindAddr(server, port)
|
||||||
|
server.listen()
|
||||||
|
while true:
|
||||||
|
let client = await server.accept()
|
||||||
|
discard await client.recvLine()
|
||||||
|
|
||||||
|
asyncCheck createServer(10335.Port)
|
||||||
|
|
||||||
proc f(): Future[void] {.async.} =
|
proc f(): Future[void] {.async.} =
|
||||||
let s = newAsyncNativeSocket()
|
let s = newAsyncNativeSocket()
|
||||||
await s.connect("example.com", 80.Port)
|
await s.connect("localhost", 10335.Port)
|
||||||
await s.send("123")
|
await s.send("123")
|
||||||
echo "Finished"
|
echo "Finished"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue