-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b5e471
commit 502f509
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import std/unittest | ||
import std/asyncdispatch | ||
|
||
from std/strformat import fmt | ||
|
||
from std/httpclient import | ||
request, | ||
HttpGet, | ||
AsyncResponse, | ||
AsyncHttpClient, | ||
newAsyncHttpClient | ||
|
||
from ../constants as constants import | ||
PORT, | ||
PING_API, | ||
HOSTNAME, | ||
PROTOCOL, | ||
STATUS_OK | ||
|
||
const SERVER_ADDRESS: string = | ||
fmt"{constants.PROTOCOL}://{constants.HOSTNAME}:{constants.PORT}" | ||
|
||
suite "APIs Test Suite": | ||
var client: AsyncHttpClient | ||
var clientPtr: ptr AsyncHttpClient = client.addr | ||
|
||
setup: | ||
client = newAsyncHttpClient() | ||
|
||
teardown: | ||
reset(client) | ||
dealloc clientPtr | ||
|
||
test "Ping API": | ||
proc ping() {.async.} = | ||
let response: AsyncResponse = await client.request( | ||
url=fmt"{SERVER_ADDRESS}{PING_API}", | ||
httpMethod=HttpGet | ||
) | ||
|
||
check response.status == constants.STATUS_OK | ||
|
||
waitFor(ping()) |