mellon-web-0.8.0.5: test/Mellon/Web/SwaggerAPISpec.hs
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Mellon.Web.SwaggerAPISpec (spec) where
import Protolude hiding (State)
import Data.Aeson (eitherDecode)
import qualified Data.ByteString.Lazy.Char8 as C8 (readFile)
import Paths_mellon_web
import Servant.Swagger.Test
import Test.Hspec
import Test.QuickCheck
(Arbitrary(..), genericShrink, oneof)
import Test.QuickCheck.Instances ()
import Mellon.Web.Server (State(..), Time(..), mellonAPI, mellonSwagger)
spec :: Spec
spec =
do describe "Swagger" $
do context "ToJSON matches ToSchema" $
validateEveryToJSON mellonAPI
context "swagger.json" $
it "matches current file contents" $
do path <- getDataFileName "swagger.json"
swagger <- eitherDecode <$> C8.readFile path
swagger `shouldBe` Right mellonSwagger
instance Arbitrary State where
arbitrary = oneof [pure Locked, Unlocked <$> arbitrary]
shrink = genericShrink
instance Arbitrary Time where
arbitrary = Time <$> arbitrary
shrink = genericShrink