@@ -7,9 +7,15 @@ import Data.Aeson
7import Data.List (isSuffixOf)
7import Data.List (isSuffixOf)
8import Data.Monoid
8import Data.Monoid
9import System.Directory (getDirectoryContents)
9import System.Directory (getDirectoryContents)
10−import Test.Tasty (defaultMain, testGroup)
10+import Test.Tasty (TestTree, defaultMain, testGroup)
11+import qualified Test.Tasty.HUnit as HU
11import Test.Tasty.QuickCheck (testProperty)
12import Test.Tasty.QuickCheck (testProperty)
15+import qualified CustomSchema as C
16+import qualified PrettyShowFailure as P
17+import qualified Standard as S
13import Data.JsonSchema.Draft4
19import Data.JsonSchema.Draft4
14import Local.Failure (correctPaths)
20import Local.Failure (correctPaths)
15import Local.Filesystem (fetchFromFilesystem)
21import Local.Filesystem (fetchFromFilesystem)
@@ -24,11 +30,23 @@ main = do
24 filenames <- filter isLocal . filter (".json" `isSuffixOf`) <$> getDirectoryContents dir
30 filenames <- filter isLocal . filter (".json" `isSuffixOf`) <$> getDirectoryContents dir
25 ts <- readSchemaTests dir filenames
31 ts <- readSchemaTests dir filenames
26 defaultMain . testGroup "Tests not requiring an HTTP server" $
32 defaultMain . testGroup "Tests not requiring an HTTP server" $
27− testProperty "Invert schemas through JSON without change" invertSchema
33+ testGroup "Check that examples compile" exampleTests
34+ : testGroup "QuickCheck tests" quickCheckTests
28 : testGroup "Report the path to invalid data correctly" correctPaths
35 : testGroup "Report the path to invalid data correctly" correctPaths
29 : testGroup "Test the referencesViaFilesystem function" fetchFromFilesystem
36 : testGroup "Test the referencesViaFilesystem function" fetchFromFilesystem
30 : testGroup "Test the Reference module" referenceTests
37 : testGroup "Test the Reference module" referenceTests
31 : fmap toTest ts
38 : fmap toTest ts
40+quickCheckTests :: [TestTree]
42+ [testProperty "Invert schemas through JSON without change" invertSchema]
33−invertSchema :: Schema -> Bool
44+ invertSchema :: Schema -> Bool
34−invertSchema a = Just a == decode (encode a)
45+ invertSchema a = Just a == decode (encode a)
47+exampleTests :: [TestTree]
49+ [ HU.testCase "Standard Example" S.example
50+ , HU.testCase "PrettyShowFailure Example" P.example
51+ , HU.testCase "CustomSchema Example" C.example