From f56a656e65bf245837b677dedb3ffd9d804cfbe1 Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Mon, 21 Sep 2015 12:46:21 +0300 Subject: [PATCH] Fix servant-docs tests --- servant-docs/test/Servant/DocsSpec.hs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/servant-docs/test/Servant/DocsSpec.hs b/servant-docs/test/Servant/DocsSpec.hs index b67d079f..9063f9a5 100644 --- a/servant-docs/test/Servant/DocsSpec.hs +++ b/servant-docs/test/Servant/DocsSpec.hs @@ -4,6 +4,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -49,14 +50,18 @@ spec = describe "Servant.Docs" $ do (toSample (Proxy :: Proxy (TT, UT))) `shouldBe` Just (TT1,UT1) (toSample (Proxy :: Proxy (TT, UT, UT))) `shouldBe` Just (TT1,UT1,UT1) (toSamples (Proxy :: Proxy (TT, UT))) `shouldBe` - [ ("(eins, yks)",(TT1,UT1)), ("(eins, kaks)",(TT1,UT2)) - , ("(zwei, yks)",(TT2,UT1)), ("(zwei, kaks)",(TT2,UT2)) + [ ("eins, yks",(TT1,UT1)), ("eins, kaks",(TT1,UT2)) + , ("zwei, yks",(TT2,UT1)), ("zwei, kaks",(TT2,UT2)) ] (toSamples (Proxy :: Proxy (TT, UT, UT))) `shouldBe` - [ ("(eins, yks, yks)",(TT1,UT1,UT1)), ("(eins, yks, kaks)",(TT1,UT1,UT2)) - , ("(eins, kaks, yks)",(TT1,UT2,UT1)), ("(eins, kaks, kaks)",(TT1,UT2,UT2)) - , ("(zwei, yks, yks)",(TT2,UT1,UT1)), ("(zwei, yks, kaks)",(TT2,UT1,UT2)) - , ("(zwei, kaks, yks)",(TT2,UT2,UT1)), ("(zwei, kaks, kaks)",(TT2,UT2,UT2)) + [ ("eins, yks, yks",(TT1,UT1,UT1)) + , ("eins, yks, kaks",(TT1,UT1,UT2)) + , ("zwei, yks, yks",(TT2,UT1,UT1)) + , ("eins, kaks, yks",(TT1,UT2,UT1)) + , ("zwei, yks, kaks",(TT2,UT1,UT2)) + , ("eins, kaks, kaks",(TT1,UT2,UT2)) + , ("zwei, kaks, yks",(TT2,UT2,UT1)) + , ("zwei, kaks, kaks",(TT2,UT2,UT2)) ] where @@ -87,13 +92,13 @@ data Datatype1 = Datatype1 { dt1field1 :: String instance ToJSON Datatype1 instance ToSample Datatype1 Datatype1 where - toSample _ = Just $ Datatype1 "field 1" 13 + toSamples _ = singleSample $ Datatype1 "field 1" 13 -instance ToSample String String where - toSample _ = Just "a string" +instance ToSample Char Char where + toSamples _ = map ("",) ['a'..'z'] instance ToSample Int Int where - toSample _ = Just 17 + toSamples _ = singleSample 17 instance MimeRender PlainText Int where mimeRender _ = cs . show @@ -105,9 +110,7 @@ data TT = TT1 | TT2 deriving (Show, Eq) data UT = UT1 | UT2 deriving (Show, Eq) instance ToSample TT TT where - toSample _ = Just TT1 toSamples _ = [("eins", TT1), ("zwei", TT2)] instance ToSample UT UT where - toSample _ = Just UT1 toSamples _ = [("yks", UT1), ("kaks", UT2)]