-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
SchemaSpec.hs
95 lines (91 loc) · 3 KB
/
SchemaSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Autodocodec.Yaml.SchemaSpec (spec) where
import Autodocodec
import Autodocodec.Usage
import Autodocodec.Yaml
import qualified Data.Aeson as JSON
import Data.Data
import Data.Int
import Data.List.NonEmpty (NonEmpty)
import Data.Map (Map)
import Data.Scientific
import Data.Set (Set)
import Data.Text (Text)
import qualified Data.Text.Lazy as LT
import Data.Time
import Data.Void
import Data.Word
import Numeric.Natural
import Test.Syd
import Test.Syd.Validity.Utils
import Text.Colour
spec :: Spec
spec = do
yamlSchemaSpec @NullUnit "null"
yamlSchemaSpec @Bool "bool"
yamlSchemaSpec @Void "void"
yamlSchemaSpec @(Either Void Bool) "either-void-bool"
yamlSchemaSpec @Ordering "ordering"
yamlSchemaSpec @Char "char"
yamlSchemaSpec @Text "text"
yamlSchemaSpec @LT.Text "lazy-text"
yamlSchemaSpec @String "string"
yamlSchemaSpec @Scientific "scientific"
yamlSchemaSpec @JSON.Object "object"
yamlSchemaSpec @JSON.Value "value"
yamlSchemaSpec @Int "int"
yamlSchemaSpec @Int8 "int8"
yamlSchemaSpec @Int16 "int16"
yamlSchemaSpec @Int32 "int32"
yamlSchemaSpec @Int64 "int64"
yamlSchemaSpec @Integer "integer"
yamlSchemaSpec @Word "word"
yamlSchemaSpec @Word8 "word8"
yamlSchemaSpec @Word16 "word16"
yamlSchemaSpec @Word32 "word32"
yamlSchemaSpec @Word64 "word64"
yamlSchemaSpec @Natural "natural"
yamlSchemaSpec @(Maybe Text) "maybe-text"
yamlSchemaSpec @(Either Bool Text) "either-bool-text"
yamlSchemaSpec @(Either (Either Bool Scientific) Text) "either-either-bool-scientific-text"
yamlSchemaSpec @[Text] "list-text"
yamlSchemaSpec @(NonEmpty Text) "nonempty-text"
yamlSchemaSpec @(Set Text) "set-text"
yamlSchemaSpec @(Map Text Int) "map-text-int"
yamlSchemaSpec @Day "day"
yamlSchemaSpec @LocalTime "local-time"
yamlSchemaSpec @UTCTime "utc-time"
yamlSchemaSpec @TimeOfDay "time-of-day"
yamlSchemaSpec @ZonedTime "zoned-time"
yamlSchemaSpec @DiffTime "difftime"
yamlSchemaSpec @NominalDiffTime "nominal-difftime"
yamlSchemaSpec @Fruit "fruit"
yamlSchemaSpec @Shape "shape"
yamlSchemaSpec @Example "example"
yamlSchemaSpec @Recursive "recursive"
yamlSchemaSpec @ListsExample "lists-example"
yamlSchemaSpec @MutuallyRecursiveA "mutually-recursive"
yamlSchemaSpec @Via "via"
yamlSchemaSpec @VeryComment "very-comment"
yamlSchemaSpec @LegacyValue "legacy-value"
yamlSchemaSpec @LegacyObject "legacy-object"
yamlSchemaSpec @Ainur "ainur"
yamlSchemaSpec @War "war"
yamlSchemaSpec @These "these"
yamlSchemaSpec @Expression "expression"
yamlSchemaSpec @MultilineDefault "multiline-default"
yamlSchemaSpec ::
forall a.
( Typeable a,
HasCodec a
) =>
FilePath ->
Spec
yamlSchemaSpec filePath = do
it ("outputs the same schema as before for " <> nameOf @a) $
pureGoldenTextFile
("test_resources/yaml-schema/" <> filePath <> ".txt")
(renderChunksText With24BitColours $ schemaChunksViaCodec @a)