From bef0e880cb4a7e6bcf34e5952be006407eb5a3ff Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Fri, 12 Jun 2015 15:45:51 +0200 Subject: [PATCH] Fix sporadic eitherDecodeLenient test failures --- servant/test/Servant/API/ContentTypesSpec.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/servant/test/Servant/API/ContentTypesSpec.hs b/servant/test/Servant/API/ContentTypesSpec.hs index 0f4a075a..407ccdb9 100644 --- a/servant/test/Servant/API/ContentTypesSpec.hs +++ b/servant/test/Servant/API/ContentTypesSpec.hs @@ -12,8 +12,6 @@ import Data.Monoid #endif import Control.Arrow import Data.Aeson -import Data.Aeson.Parser (jstring) -import Data.Attoparsec.ByteString (parseOnly) import Data.Either import Data.Function (on) import Data.Proxy @@ -164,11 +162,14 @@ spec = describe "Servant.API.ContentTypes" $ do describe "eitherDecodeLenient" $ do + -- aeson >= 0.9 decodes top-level strings +#if MIN_VERSION_aeson(0,9,0) it "parses top-level strings" $ do let toMaybe = either (const Nothing) Just -- The Left messages differ, so convert to Maybe property $ \x -> toMaybe (eitherDecodeLenient x) - `shouldBe` toMaybe (parseOnly jstring $ cs x) + `shouldBe` (decode x :: Maybe String) +#endif data SomeData = SomeData { record1 :: String, record2 :: Int }