Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Improve test coverage, close #10
Browse files Browse the repository at this point in the history
  • Loading branch information
IainNZ committed Aug 27, 2014
1 parent 9318090 commit 2c839b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/REQUIRE
@@ -1 +1,2 @@
FactCheck
FactCheck
Requests
27 changes: 26 additions & 1 deletion test/runtests.jl
@@ -1,6 +1,6 @@
using HttpCommon
using FactCheck
import HttpServer
using HttpServer

facts("HttpServer utility functions") do
context("HttpServer.write does sensible things") do
Expand All @@ -19,3 +19,28 @@ facts("HttpServer utility functions") do
@fact grep(vals, "Hello") => "Hello World!"
end
end

import Requests

facts("HttpServer run") do
context("HttpServer can run the example") do
http = HttpHandler() do req::Request, res::Response
Response( ismatch(r"^/hello/",req.resource) ? string("Hello ", split(req.resource,'/')[3], "!") : 404 )
end
http.events["error"] = (client, err) -> println(err)
http.events["listen"] = (port ) -> println("Listening on $port...")

server = Server(http)
@async run(server, 8000)
sleep(1.0)

ret = Requests.get("http://localhost:8000/hello/travis")
@fact ret.data => "Hello travis!"
@fact ret.status => 200

ret = Requests.get("http://localhost:8000/bad")
@fact ret.data => ""
@fact ret.status => 404
end
end

0 comments on commit 2c839b1

Please sign in to comment.