renamed Request to GemURL
- A request should contain a URL and an optional client certigicate. - renamed accompanying functions accordingly
This commit is contained in:
@@ -29,38 +29,38 @@ import Network.GemServ.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Network.GemServ" $ do
|
||||
encodeRequestSpec
|
||||
encodeGemURLSpec
|
||||
escapeStringSpec
|
||||
unescapeStringSpec
|
||||
|
||||
encodeRequestSpec :: Spec
|
||||
encodeRequestSpec = describe "encodeRequest" $ mapM_
|
||||
encodeGemURLSpec :: Spec
|
||||
encodeGemURLSpec = describe "encodeGemURL" $ mapM_
|
||||
( \(desc, req, expected) -> context desc $
|
||||
it ("should be " ++ show expected) $
|
||||
encodeRequest req `shouldBe` expected
|
||||
encodeGemURL req `shouldBe` expected
|
||||
)
|
||||
|
||||
-- description, request, expected
|
||||
[ ( "simple", simpleReq, simpleExp )
|
||||
, ( "with port", withPortReq, withPortExp )
|
||||
, ( "with path", withPathReq, withPathExp )
|
||||
, ( "with query", withQueryReq, withQueryExp )
|
||||
, ( "with escape", withEscapeReq, withEscapeExp )
|
||||
[ ( "simple", simpleURL, simpleExp )
|
||||
, ( "with port", withPortURL, withPortExp )
|
||||
, ( "with path", withPathURL, withPathExp )
|
||||
, ( "with query", withQueryURL, withQueryExp )
|
||||
, ( "with escape", withEscapeURL, withEscapeExp )
|
||||
]
|
||||
|
||||
where
|
||||
simpleReq = newRequest "example.com"
|
||||
simpleURL = newGemURL "example.com"
|
||||
simpleExp = "gemini://example.com/"
|
||||
withPortReq = simpleReq { reqPort = Just 1965 }
|
||||
withPortURL = simpleURL { gemPort = Just 1965 }
|
||||
withPortExp = "gemini://example.com:1965/"
|
||||
withPathReq = simpleReq { reqPath = ["foo", "bar"] }
|
||||
withPathURL = simpleURL { gemPath = ["foo", "bar"] }
|
||||
withPathExp = "gemini://example.com/foo/bar"
|
||||
withQueryReq = simpleReq { reqQuery = "foo" }
|
||||
withQueryURL = simpleURL { gemQuery = "foo" }
|
||||
withQueryExp = "gemini://example.com/?foo"
|
||||
|
||||
withEscapeReq = simpleReq
|
||||
{ reqPath = ["foo bar"]
|
||||
, reqQuery = "baz quux"
|
||||
withEscapeURL = simpleURL
|
||||
{ gemPath = ["foo bar"]
|
||||
, gemQuery = "baz quux"
|
||||
}
|
||||
|
||||
withEscapeExp = "gemini://example.com/foo%20bar?baz%20quux"
|
||||
|
||||
Reference in New Issue
Block a user