on master help sign in
Add test for safeLink applied to an EmptyAPI type
7d07db7David Turner
servant/test/Servant/Utils/LinksSpec.hs+7
@@ -25,6 +25,7 @@ type TestApi =
25 :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] NoContent
25 :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] NoContent
26 :<|> "delete" :> Header "ponies" String :> Delete '[JSON] NoContent
26 :<|> "delete" :> Header "ponies" String :> Delete '[JSON] NoContent
27 :<|> "raw" :> Raw
27 :<|> "raw" :> Raw
28+ :<|> NoEndpoint
28
29
29
30
30apiLink :: (IsElem endpoint TestApi, HasLink endpoint)
31apiLink :: (IsElem endpoint TestApi, HasLink endpoint)
@@ -98,6 +99,11 @@ spec = describe "Servant.Utils.Links" $ do
98-- ...Could not deduce...
99-- ...Could not deduce...
99-- ...
100-- ...
100--
101--
102+-- >>> apiLink (Proxy :: Proxy NoEndpoint)
103+-- ...
104+-- ...No instance for...
105+-- ...
106+--
101-- sanity check
107-- sanity check
102-- >>> toUrlPiece $ apiLink (Proxy :: Proxy AllGood)
108-- >>> toUrlPiece $ apiLink (Proxy :: Proxy AllGood)
103-- "get"
109-- "get"
@@ -107,3 +113,4 @@ type WrongContentType = "get" :> Get '[OctetStream] NoContent
107type WrongMethod = "get" :> Post '[JSON] NoContent
113type WrongMethod = "get" :> Post '[JSON] NoContent
108type NotALink = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool
114type NotALink = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool
109type AllGood = "get" :> Get '[JSON] NoContent
115type AllGood = "get" :> Get '[JSON] NoContent
116+type NoEndpoint = "empty" :> EmptyAPI