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