@@ -2,24 +2,18 @@
3module SchemaSpec (spec, main) where
3module SchemaSpec (spec, main) where
6import Data.ByteString.Lazy
5import Data.ByteString.Lazy
7import Data.Aeson
6import Data.Aeson
8import Data.Proxy
7import Data.Proxy
9import Data.Schematic
8import Data.Schematic
10−import Data.Singletons
11−import Data.Singletons.Prelude
12import Data.Vinyl
9import Data.Vinyl
13import Test.Hspec
10import Test.Hspec
14−import Test.Hspec.SmallCheck
15−import Test.SmallCheck
16−import Test.SmallCheck.Series.Instances
19type SchemaExample
13type SchemaExample
20 = 'SchemaObject
14 = 'SchemaObject
21− '[ '("foo", 'SchemaArray '[AEq 1] ('SchemaNumber '[NGt 10]))
15+ '[ '("foo", 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10]))
22− , '("bar", 'SchemaOptional ('SchemaText '[TEnum '["foo", "bar"]]))]
16+ , '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
24type TestMigration =
18type TestMigration =
25 'Migration "test_revision"
19 'Migration "test_revision"
@@ -28,15 +22,6 @@ type TestMigration =
29type VS = 'Versioned SchemaExample '[ TestMigration ]
23type VS = 'Versioned SchemaExample '[ TestMigration ]
31−exampleTest :: JsonRepr (SchemaOptional (SchemaText '[TEq 3]))
32−exampleTest = ReprOptional (Just (ReprText "lil"))
34−exampleNumber :: JsonRepr (SchemaNumber '[NGt 10])
35−exampleNumber = ReprNumber 12
37−exampleArray :: JsonRepr (SchemaArray '[AEq 1] (SchemaNumber '[NGt 10]))
38−exampleArray = ReprArray [exampleNumber]
40jsonExample :: JsonRepr SchemaExample
25jsonExample :: JsonRepr SchemaExample
41jsonExample = ReprObject $
26jsonExample = ReprObject $
42 FieldRepr (ReprArray [ReprNumber 12])
27 FieldRepr (ReprArray [ReprNumber 12])
@@ -49,9 +34,6 @@ schemaJson = "{\"foo\": [13], \"bar\": null}"
49schemaJson2 :: ByteString
34schemaJson2 :: ByteString
50schemaJson2 = "{\"foo\": [3], \"bar\": null}"
35schemaJson2 = "{\"foo\": [3], \"bar\": null}"
52−schemaJsonTopVersion :: ByteString
53−schemaJsonTopVersion = "{ \"foo\": 42, \"bar\": \"bar\" }"
56 :: JsonRepr
38 :: JsonRepr
57 ('SchemaObject
39 ('SchemaObject
@@ -88,7 +70,7 @@ spec = do
88 it "validates versioned json" $ do
70 it "validates versioned json" $ do
89 decodeAndValidateVersionedJson (Proxy @VS) schemaJson
71 decodeAndValidateVersionedJson (Proxy @VS) schemaJson
90 `shouldSatisfy` isValid
72 `shouldSatisfy` isValid
91− it "validates with Migration List" $ do
73+ it "validates versioned json with a migration list" $ do
92 decodeAndValidateVersionedWithMList
74 decodeAndValidateVersionedWithMList
93 (Proxy @VS)
75 (Proxy @VS)
94 ((:&&) (Proxy @(SchemaByRevision "test_revision" VS)) (const topObject) MNil)
76 ((:&&) (Proxy @(SchemaByRevision "test_revision" VS)) (const topObject) MNil)