fixes failing utf8 test case

it was a buggy test case, not related to windows
but by chance discovered on windows.
This commit is contained in:
jangko 2021-06-12 12:35:56 +07:00
parent 480560c7c8
commit 88e99ff028
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 6 additions and 16 deletions

View File

@ -162,14 +162,13 @@ suite "UTF-8 validator in action":
await session.close(reason = closeReason)
test "invalid UTF-8 sequence":
# TODO: how to check for Invalid UTF8 exception?
let testData = "hello world\xc0\xaf"
proc handle(request: HttpRequest) {.async.} =
check request.uri.path == "/ws"
let server = WSServer.new(protos = ["proto"])
let ws = await server.handleRequest(request)
discard await ws.recv()
await ws.send(testData)
await waitForClose(ws)
server = HttpServer.create(
@ -185,25 +184,17 @@ suite "UTF-8 validator in action":
protocols = @["proto"]
)
await session.send(testData)
await session.close()
check session.readyState == ReadyState.Closed
expect WSInvalidUTF8:
let data = await session.recv()
test "invalid UTF-8 sequence close code":
# TODO: how to check for Invalid UTF8 exception?
let testData = "hello world"
let closeReason = "i want to close\xc0\xaf"
proc handle(request: HttpRequest) {.async.} =
check request.uri.path == "/ws"
let server = WSServer.new(protos = ["proto"])
let ws = await server.handleRequest(request)
let res = await ws.recv()
check:
string.fromBytes(res) == testData
ws.binary == false
await ws.close(reason = closeReason)
await waitForClose(ws)
server = HttpServer.create(
@ -219,6 +210,5 @@ suite "UTF-8 validator in action":
protocols = @["proto"]
)
await session.send(testData)
await session.close(reason = closeReason)
check session.readyState == ReadyState.Closed
expect WSInvalidUTF8:
let data = await session.recv()