Skip to content

Commit

Permalink
fix and test for timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mishankov committed Jan 21, 2024
1 parent 5777281 commit ce207bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/yahttp/internal/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ macro http_method_gen*(name: untyped): untyped =
query = query,
body = body,
auth = auth,
timeout = timeout,
ignoreSsl = ignoreSsl
)

Expand All @@ -34,5 +35,6 @@ macro http_method_no_body_gen*(name: untyped): untyped =
headers = headers,
query = query,
auth = auth,
timeout = timeout,
ignoreSsl = ignoreSsl
)
7 changes: 7 additions & 0 deletions tests/int/test_yahttp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ test "Test JSON body":
let jsonResp = put(BASE_URL & "/put", headers = {"Content-Type": "application/json"}, body = $ %*{"key": "value"}).json()

check jsonResp["json"]["key"].getStr() == "value"

test "Test timeout":
expect TimeoutError:
discard get(BASE_URL & "/delay/5", timeout = 100)

# No exception
discard get(BASE_URL & "/delay/5", timeout = -1)

0 comments on commit ce207bc

Please sign in to comment.