2017-05-25 19:12:29 +00:00
|
|
|
module HTTPure.ServerSpec where
|
|
|
|
|
2017-07-18 05:31:46 +00:00
|
|
|
import Prelude
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import Control.Monad.Eff.Class as EffClass
|
2017-07-14 06:28:57 +00:00
|
|
|
import Data.StrMap as StrMap
|
2017-07-10 10:17:13 +00:00
|
|
|
import Test.Spec as Spec
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-14 06:28:57 +00:00
|
|
|
import HTTPure.Request as Request
|
|
|
|
import HTTPure.Response as Response
|
|
|
|
import HTTPure.Server as Server
|
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import HTTPure.SpecHelpers as SpecHelpers
|
2017-07-19 05:36:56 +00:00
|
|
|
import HTTPure.SpecHelpers ((?=))
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-14 06:28:57 +00:00
|
|
|
mockRouter :: forall e. Request.Request -> Response.ResponseM e
|
|
|
|
mockRouter (Request.Get _ path) = pure $ Response.OK StrMap.empty path
|
|
|
|
mockRouter _ = pure $ Response.OK StrMap.empty ""
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
serveSpec :: SpecHelpers.Test
|
2017-07-14 06:28:57 +00:00
|
|
|
serveSpec = Spec.describe "serve" do
|
2017-07-10 10:17:13 +00:00
|
|
|
Spec.it "boots a server on the given port" do
|
2017-07-14 06:28:57 +00:00
|
|
|
EffClass.liftEff $ Server.serve 7901 mockRouter $ pure unit
|
2017-07-18 17:09:03 +00:00
|
|
|
out <- SpecHelpers.get 7901 StrMap.empty "/test"
|
2017-07-19 05:36:56 +00:00
|
|
|
out ?= "/test"
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
serverSpec :: SpecHelpers.Test
|
|
|
|
serverSpec = Spec.describe "Server" do
|
2017-05-25 19:12:29 +00:00
|
|
|
serveSpec
|