on master help sign in
fix warnings
commit5771fa9b6626b3ff05e5b15f791c6d2ccc1ea6bf authorDenis Redozubov <denis.redozubov@gmail.com> dateWed 30 Aug 2017, 19:56 (9 years ago) parent0df72db
4 files changed+11−27
schematic.cabal+3−1 src/Data/Schematic/JsonSchema.hs+1 test/LensSpec.hs+4−5 test/SchemaSpec.hs+3−21
schematic.cabal+3−1
@@ -133,4 +133,6 @@ test-suite spec
133133 , validationt >= 0.1.0.1
134134 , vinyl
135135 other-modules: SchemaSpec
136− , LensSpec
136+ , LensSpec
137+ , JsonSchemaSpec
138+ , MigrationSpec
src/Data/Schematic/JsonSchema.hs+1
@@ -4,6 +4,7 @@
44
55module Data.Schematic.JsonSchema
66 ( toJsonSchema
7+ , toJsonSchema
78 ) where
89
910import Control.Monad.State.Strict
test/LensSpec.hs+4−5
@@ -8,12 +8,12 @@ import Data.Vinyl
88import Test.Hspec
99
1010
11−type ArraySchema = 'SchemaArray '[AEq 1] ('SchemaNumber '[NGt 10])
11+type ArraySchema = 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10])
1212
1313type ArrayField = '("foo", ArraySchema)
1414
1515type FieldsSchema =
16− '[ ArrayField, '("bar", 'SchemaOptional ('SchemaText '[TEnum '["foo", "bar"]]))]
16+ '[ ArrayField, '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
1717
1818type SchemaExample = 'SchemaObject FieldsSchema
1919
@@ -164,8 +164,8 @@ type BigRecord = Rec FieldRepr
164164 , '("f130", 'SchemaNumber '[])
165165 ]
166166
167−bigRecord :: BigRecord
168−bigRecord =
167+_bigRecord :: BigRecord
168+_bigRecord =
169169 FieldRepr (ReprNumber 1)
170170 :& FieldRepr (ReprNumber 2)
171171 :& FieldRepr (ReprNumber 3)
@@ -298,7 +298,6 @@ bigRecord =
298298 :& FieldRepr (ReprNumber 130)
299299 :& RNil
300300
301−
302301spec :: Spec
303302spec = do
304303 let
test/SchemaSpec.hs+3−21
@@ -2,24 +2,18 @@
22
33module SchemaSpec (spec, main) where
44
5−import Control.Monad
65import Data.ByteString.Lazy
76import Data.Aeson
87import Data.Proxy
98import Data.Schematic
10−import Data.Singletons
11−import Data.Singletons.Prelude
129import Data.Vinyl
1310import Test.Hspec
14−import Test.Hspec.SmallCheck
15−import Test.SmallCheck
16−import Test.SmallCheck.Series.Instances
1711
1812
1913type SchemaExample
2014 = 'SchemaObject
21− '[ '("foo", 'SchemaArray '[AEq 1] ('SchemaNumber '[NGt 10]))
22− , '("bar", 'SchemaOptional ('SchemaText '[TEnum '["foo", "bar"]]))]
15+ '[ '("foo", 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10]))
16+ , '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
2317
2418type TestMigration =
2519 'Migration "test_revision"
@@ -28,15 +22,6 @@ type TestMigration =
2822
2923type VS = 'Versioned SchemaExample '[ TestMigration ]
3024
31−exampleTest :: JsonRepr (SchemaOptional (SchemaText '[TEq 3]))
32−exampleTest = ReprOptional (Just (ReprText "lil"))
33−
34−exampleNumber :: JsonRepr (SchemaNumber '[NGt 10])
35−exampleNumber = ReprNumber 12
36−
37−exampleArray :: JsonRepr (SchemaArray '[AEq 1] (SchemaNumber '[NGt 10]))
38−exampleArray = ReprArray [exampleNumber]
39−
4025jsonExample :: JsonRepr SchemaExample
4126jsonExample = ReprObject $
4227 FieldRepr (ReprArray [ReprNumber 12])
@@ -49,9 +34,6 @@ schemaJson = "{\"foo\": [13], \"bar\": null}"
4934schemaJson2 :: ByteString
5035schemaJson2 = "{\"foo\": [3], \"bar\": null}"
5136
52−schemaJsonTopVersion :: ByteString
53−schemaJsonTopVersion = "{ \"foo\": 42, \"bar\": \"bar\" }"
54−
5537topObject
5638 :: JsonRepr
5739 ('SchemaObject
@@ -88,7 +70,7 @@ spec = do
8870 it "validates versioned json" $ do
8971 decodeAndValidateVersionedJson (Proxy @VS) schemaJson
9072 `shouldSatisfy` isValid
91− it "validates with Migration List" $ do
73+ it "validates versioned json with a migration list" $ do
9274 decodeAndValidateVersionedWithMList
9375 (Proxy @VS)
9476 ((:&&) (Proxy @(SchemaByRevision "test_revision" VS)) (const topObject) MNil)