mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 06:20:38 +00:00
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:
committed by
Andreas Rumpf
parent
253ae4e25e
commit
b7ea1b0819
@@ -3,11 +3,22 @@ discard """
|
||||
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.} =
|
||||
let s = newAsyncNativeSocket()
|
||||
await s.connect("example.com", 80.Port)
|
||||
await s.connect("localhost", 10335.Port)
|
||||
await s.send("123")
|
||||
echo "Finished"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user