More tests
This commit is contained in:
parent
fb29a6e694
commit
7928aa1cb6
@ -92,14 +92,55 @@ test-suite spec
|
||||
main-is: Spec.hs
|
||||
hs-source-dirs: src
|
||||
build-depends: base >=4.10
|
||||
, exceptions
|
||||
, monad-control
|
||||
, common
|
||||
, aeson
|
||||
, asn1-data
|
||||
, asn1-types
|
||||
, bytestring
|
||||
, classy-prelude
|
||||
, cryptonite
|
||||
, dhall
|
||||
, directory
|
||||
, foreign-store
|
||||
, generic-lens
|
||||
, http-api-data
|
||||
, http-media
|
||||
, jose
|
||||
, lens
|
||||
, lucid
|
||||
, memory
|
||||
, monad-logger
|
||||
, mtl
|
||||
, pandoc
|
||||
, pandoc-types
|
||||
, pem
|
||||
, process
|
||||
, resource-pool
|
||||
, selda
|
||||
, selda-postgresql
|
||||
, aeson
|
||||
, servant
|
||||
, servant-auth
|
||||
, servant-auth-server
|
||||
, servant-docs
|
||||
, servant-lucid
|
||||
, servant-multipart
|
||||
, servant-server
|
||||
, text
|
||||
, transformers
|
||||
, wai
|
||||
, warp
|
||||
, x509
|
||||
, x509-store
|
||||
, xml-conduit
|
||||
, xml-hamlet
|
||||
, validity
|
||||
, genvalidity-hspec
|
||||
, genvalidity-property
|
||||
, genvalidity-text
|
||||
, hspec
|
||||
default-extensions: DeriveGeneric
|
||||
, NoImplicitPrelude
|
||||
, OverloadedStrings
|
||||
, RecordWildCards
|
@ -41,14 +41,14 @@ data JsonBook = JsonBook { identifier :: BookID
|
||||
, description :: Maybe Text
|
||||
, channels :: [Text]
|
||||
, tags :: [Text] }
|
||||
deriving (Generic, Show)
|
||||
deriving (Generic, Show, Eq)
|
||||
|
||||
data PostBook = PostBook { contentType :: Text
|
||||
, title :: Text
|
||||
, description :: Maybe Text
|
||||
, channels :: [Text]
|
||||
, tags :: [Text] }
|
||||
deriving (Generic, Show)
|
||||
deriving (Generic, Show, Eq)
|
||||
|
||||
|
||||
instance ToJSON JsonBook
|
||||
|
@ -1,11 +1,13 @@
|
||||
{-# Language TypeApplications #-}
|
||||
module Main where
|
||||
|
||||
import API.Books
|
||||
import qualified Data.Aeson as A
|
||||
import Data.Char (isPrint)
|
||||
import Data.GenValidity.Text ()
|
||||
import qualified Data.Text as T
|
||||
import Database.Schema
|
||||
import Prelude
|
||||
import Test.Hspec
|
||||
import Test.Validity
|
||||
|
||||
@ -37,6 +39,14 @@ instance GenUnchecked Visibility
|
||||
instance GenValid Visibility
|
||||
instance GenInvalid Visibility
|
||||
instance Validity Visibility
|
||||
instance GenUnchecked JsonBook
|
||||
instance GenValid JsonBook
|
||||
instance GenInvalid JsonBook
|
||||
instance Validity JsonBook
|
||||
instance GenUnchecked PostBook
|
||||
instance GenValid PostBook
|
||||
instance GenInvalid PostBook
|
||||
instance Validity PostBook
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
@ -48,6 +58,8 @@ spec = do
|
||||
it "Works for ChannelID" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @ChannelID) A.decode
|
||||
it "Works for Role" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @Role) A.decode
|
||||
it "Works for Visibility" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @Visibility) A.decode
|
||||
it "Works for JsonBook" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @JsonBook) A.decode
|
||||
it "Works for PostBook" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @PostBook) A.decode
|
||||
|
||||
main :: IO ()
|
||||
main = hspec spec
|
||||
|
Loading…
Reference in New Issue
Block a user