Fix tests

This commit is contained in:
Mats Rauhala 2019-01-21 21:31:13 +02:00
parent c45ea0ecc8
commit 908db84232
2 changed files with 24 additions and 22 deletions

View File

@ -94,25 +94,30 @@ 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 , aeson
, asn1-data , asn1-data
, asn1-types , asn1-types
, bytestring , bytestring
, classy-prelude , classy-prelude
, common
, cryptonite , cryptonite
, dhall , dhall
, directory , directory
, exceptions
, foreign-store , foreign-store
, generic-lens , generic-lens
, genvalidity-hspec
, genvalidity-hspec-aeson
, genvalidity-property
, genvalidity-text
, hspec
, http-api-data , http-api-data
, http-media , http-media
, jose , jose
, lens , lens
, lucid , lucid
, memory , memory
, monad-control
, monad-logger , monad-logger
, mtl , mtl
, pandoc , pandoc
@ -124,25 +129,21 @@ test-suite spec
, selda-postgresql , selda-postgresql
, servant , servant
, servant-auth , servant-auth
, servant-auth-docs
, servant-auth-server , servant-auth-server
, servant-docs , servant-docs
, servant-auth-docs
, servant-lucid , servant-lucid
, servant-multipart , servant-multipart
, servant-server , servant-server
, text , text
, transformers , transformers
, validity
, wai , wai
, warp , warp
, x509 , x509
, x509-store , x509-store
, xml-conduit , xml-conduit
, xml-hamlet , xml-hamlet
, validity
, genvalidity-hspec
, genvalidity-property
, genvalidity-text
, hspec
default-extensions: DeriveGeneric default-extensions: DeriveGeneric
, NoImplicitPrelude , NoImplicitPrelude
, OverloadedStrings , OverloadedStrings

View File

@ -1,4 +1,4 @@
{-# Language TypeApplications #-} {-# LANGUAGE TypeApplications #-}
module Main where module Main where
import API.Books import API.Books
@ -10,6 +10,7 @@ import Database.Schema
import Prelude import Prelude
import Test.Hspec import Test.Hspec
import Test.Validity import Test.Validity
import Test.Validity.Aeson
instance GenUnchecked PlainPassword instance GenUnchecked PlainPassword
instance GenValid PlainPassword instance GenValid PlainPassword
@ -51,15 +52,15 @@ instance Validity PostBook
spec :: Spec spec :: Spec
spec = do spec = do
describe "JSON encoding" $ do describe "JSON encoding" $ do
it "Works for PlainPassword" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @PlainPassword) A.decode jsonSpecOnValid @PlainPassword
it "Works for Email" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @Email) A.decode jsonSpecOnValid @Email
it "Username" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @Username) A.decode jsonSpecOnValid @Username
it "Works for BookID" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @BookID) A.decode jsonSpecOnValid @BookID
it "Works for ChannelID" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @ChannelID) A.decode jsonSpecOnValid @ChannelID
it "Works for Role" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @Role) A.decode jsonSpecOnValid @Role
it "Works for Visibility" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @Visibility) A.decode jsonSpecOnValid @Visibility
it "Works for JsonBook" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @JsonBook) A.decode jsonSpecOnValid @JsonBook
it "Works for PostBook" $ inverseFunctionsIfSecondSucceedsOnValid (A.encode @PostBook) A.decode jsonSpecOnValid @PostBook
main :: IO () main :: IO ()
main = hspec spec main = hspec spec