Skip to content

Commit

Permalink
Add test for resp.
Browse files Browse the repository at this point in the history
  • Loading branch information
dom96 committed Jun 19, 2016
1 parent 432e032 commit 805e573
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions tests/alltest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ routes:
get "/":
resp "Hello World"

get "/resp":
if true:
resp "This should be the response"
resp "This should NOT be the response"

get "/halt":
halt Http502, "I'm sorry, this page has been halted."
resp "test"
Expand Down
9 changes: 6 additions & 3 deletions tests/tester.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2015 Dominik Picheta
# MIT License - Look at license.txt for details.
import unittest, httpclient, strutils, asyncdispatch, strtabs
import unittest, httpclient, strutils, asyncdispatch

const port = 5454

Expand All @@ -25,9 +25,12 @@ test "/guess":

test "/redirect":
let resp = waitFor client.request("http://localhost:" & $port & "/foo/redirect/halt", httpGet)
# TODO: Should this not contain the port?
check resp.headers["location"] == "http://localhost/foo/halt"
check resp.headers["location"] == "http://localhost:5454/foo/halt"

test "regex":
let resp = waitFor client.get("http://localhost:" & $port & "/foo/02.html")
check resp.body == "02"

test "resp":
let resp = waitFor client.get("http://localhost:" & $port & "/foo/resp")
check resp.body == "This should be the response"

0 comments on commit 805e573

Please sign in to comment.