git.iko.soy/typeable/hjsonschema
on master help sign in
No need for examples to have their own test suite.
commitd69cd9e47ad4fb08ad3ea8eb21161e061a9d7b0c authorIan Grant Jeffries <ian@housejeffries.com> dateMon 2 May 2016, 18:43 (10 years ago) parent53a7789
3 files changed+28−41
examples/Main.hs−19 hjsonschema.cabal+6−18 tests/Local.hs+22−4
examples/Main.hsdeleted−19
@@ -1,19 +0,0 @@
1−
2−module Main where
3−
4−import Test.Tasty (TestTree, defaultMain, testGroup)
5−import qualified Test.Tasty.HUnit as HU
6−
7−import qualified CustomSchema as C
8−import qualified PrettyShowFailure as P
9−import qualified Standard as S
10−
11−main :: IO ()
12−main = defaultMain (testGroup "Check Examples" exampleTests)
13−
14−exampleTests :: [TestTree]
15−exampleTests =
16− [ HU.testCase "Standard Example" S.example
17− , HU.testCase "PrettyShowFailure Example" P.example
18− , HU.testCase "CustomSchema Example" C.example
19− ]
hjsonschema.cabal+6−18
@@ -61,11 +61,17 @@ library
6161test-suite local
6262 type: exitcode-stdio-1.0
6363 hs-source-dirs: tests
64+ examples
6465 main-is: Local.hs
6566 other-modules: Local.Failure
6667 , Local.Filesystem
6768 , Local.Reference
6869 , Shared
70+ -- from ./examples:
71+ , CustomSchema
72+ , PrettyShowFailure
73+ , Standard
74+
6975 default-language: Haskell2010
7076 ghc-options: -Wall -fno-warn-orphans
7177 default-extensions: OverloadedStrings
@@ -108,24 +114,6 @@ test-suite remote
108114 , wai-app-static
109115 , warp
110116
111−test-suite example
112− type: exitcode-stdio-1.0
113− hs-source-dirs: examples
114− main-is: Main.hs
115− other-modules: CustomSchema
116− , PrettyShowFailure
117− , Standard
118− default-language: Haskell2010
119− ghc-options: -Wall
120− build-depends: aeson
121− , base
122− , hjsonpointer
123− , hjsonschema
124− , tasty
125− , tasty-hunit
126− , text
127− , vector
128−
129117source-repository head
130118 type: git
131119 location: git://github.com/seagreen/hjsonschema.git
tests/Local.hs+22−4
@@ -7,9 +7,15 @@ import Data.Aeson
77import Data.List (isSuffixOf)
88import Data.Monoid
99import System.Directory (getDirectoryContents)
10−import Test.Tasty (defaultMain, testGroup)
10+import Test.Tasty (TestTree, defaultMain, testGroup)
11+import qualified Test.Tasty.HUnit as HU
1112import Test.Tasty.QuickCheck (testProperty)
1213
14+-- Examples
15+import qualified CustomSchema as C
16+import qualified PrettyShowFailure as P
17+import qualified Standard as S
18+
1319import Data.JsonSchema.Draft4
1420import Local.Failure (correctPaths)
1521import Local.Filesystem (fetchFromFilesystem)
@@ -24,11 +30,23 @@ main = do
2430 filenames <- filter isLocal . filter (".json" `isSuffixOf`) <$> getDirectoryContents dir
2531 ts <- readSchemaTests dir filenames
2632 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
2835 : testGroup "Report the path to invalid data correctly" correctPaths
2936 : testGroup "Test the referencesViaFilesystem function" fetchFromFilesystem
3037 : testGroup "Test the Reference module" referenceTests
3138 : fmap toTest ts
3239
33−invertSchema :: Schema -> Bool
34−invertSchema a = Just a == decode (encode a)
40+quickCheckTests :: [TestTree]
41+quickCheckTests =
42+ [testProperty "Invert schemas through JSON without change" invertSchema]
43+ where
44+ invertSchema :: Schema -> Bool
45+ invertSchema a = Just a == decode (encode a)
46+
47+exampleTests :: [TestTree]
48+exampleTests =
49+ [ HU.testCase "Standard Example" S.example
50+ , HU.testCase "PrettyShowFailure Example" P.example
51+ , HU.testCase "CustomSchema Example" C.example
52+ ]