Skip to content

Commit

Permalink
Another improvement to CI flakiness.
Browse files Browse the repository at this point in the history
  • Loading branch information
dom96 committed Dec 14, 2021
1 parent 70f7291 commit 869eb42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/simpleLog.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ proc onRequest(req: Request): Future[void] =
case req.path.get()
of "/":
info("Requested /")
flushFile(logFile) # Only errors above lvlError auto-flush
req.send("Hello World")
else:
info("Requested ", req.path.get())
error("404")
req.send(Http404)

flushFile(logFile) # Only errors above lvlError auto-flush

block:
let settings = initSettings()

Expand Down
10 changes: 8 additions & 2 deletions tests/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ proc tests() {.async.} =
let client = newAsyncHttpClient()
let resp = await client.get("http://localhost:8080")
check resp.code == Http200
check logFilename.readLines() == @["INFO Requested /"]
let file = open(logFilename)
check "INFO Requested /" in file.readAll()
file.close()

check tryRemoveFile(logFilename)
await startServer("simpleLog.nim")
Expand All @@ -93,7 +95,11 @@ proc tests() {.async.} =
let client = newAsyncHttpClient()
let resp = await client.get("http://localhost:8080/404")
check resp.code == Http404
check logFilename.readLines(2) == @["INFO Requested /404", "ERROR 404"]
let file = open(logFilename)
let contents = file.readAll()
file.close()
check "INFO Requested /404" in contents
check "ERROR 404" in contents

check tryRemoveFile(logFilename)

Expand Down

0 comments on commit 869eb42

Please sign in to comment.