packages feed

sydtest-autodocodec (empty) → 0.0.0.0

raw patch · 7 files changed

+128/−0 lines, 7 filesdep +autodocodecdep +autodocodec-yamldep +base

Dependencies added: autodocodec, autodocodec-yaml, base, sydtest, sydtest-autodocodec, text

Files

+ LICENSE.md view
@@ -0,0 +1,5 @@+# Sydtest License++Copyright (c) 2022 Tom Sydney Kerckhove++See the Sydtest License at https://github.com/NorfairKing/sydtest/blob/master/sydtest/LICENSE.md for the full license text.
+ src/Test/Syd/Autodocodec.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}++module Test.Syd.Autodocodec+  ( -- * Golden tests+    goldenYamlSchemaFileVia,+    pureGoldenYamlSchemaFileVia,+    pureGoldenYamlSchemaFileViaCodec,+  )+where++import Autodocodec+import Autodocodec.Yaml+import Data.Text (Text)+import Test.Syd++-- | Test that the Yaml schema of the produced 'Codec' is the same as what we find in the given golden file.+goldenYamlSchemaFileVia :: FilePath -> IO (ValueCodec input output) -> GoldenTest Text+goldenYamlSchemaFileVia fp produceCodec = goldenTextFile fp (renderColouredSchemaVia <$> produceCodec)++-- | Test that the Yaml schema of the given 'Codec' is the same as what we find in the given golden file.+pureGoldenYamlSchemaFileVia :: FilePath -> ValueCodec input output -> GoldenTest Text+pureGoldenYamlSchemaFileVia fp c = goldenYamlSchemaFileVia fp $ pure c++-- | Test that the Yaml schema of the 'Codec' of the given type is the same as what we find in the given golden file.+pureGoldenYamlSchemaFileViaCodec :: forall a. HasCodec a => FilePath -> GoldenTest Text+pureGoldenYamlSchemaFileViaCodec fp = pureGoldenYamlSchemaFileVia fp (codec @a)
+ sydtest-autodocodec.cabal view
@@ -0,0 +1,59 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.34.7.+--+-- see: https://github.com/sol/hpack++name:           sydtest-autodocodec+version:        0.0.0.0+synopsis:       An autodocodec companion library for sydtest+category:       Testing+homepage:       https://github.com/NorfairKing/sydtest#readme+bug-reports:    https://github.com/NorfairKing/sydtest/issues+author:         Tom Sydney Kerckhove+maintainer:     syd@cs-syd.eu+copyright:      Copyright (c) 2022 Tom Sydney Kerckhove+license:        OtherLicense+license-file:   LICENSE.md+build-type:     Simple+extra-source-files:+    LICENSE.md+    test_resources/example.txt+    test_resources/int.txt++source-repository head+  type: git+  location: https://github.com/NorfairKing/sydtest++library+  exposed-modules:+      Test.Syd.Autodocodec+  other-modules:+      Paths_sydtest_autodocodec+  hs-source-dirs:+      src+  build-depends:+      autodocodec+    , autodocodec-yaml+    , base >=4.7 && <5+    , sydtest+    , text+  default-language: Haskell2010++test-suite sydtest-aeson-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Test.Syd.AutodocodecSpec+      Paths_sydtest_autodocodec+  hs-source-dirs:+      test+  ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+  build-tool-depends:+      sydtest-discover:sydtest-discover+  build-depends:+      autodocodec+    , base >=4.7 && <5+    , sydtest+    , sydtest-autodocodec+  default-language: Haskell2010
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF sydtest-discover #-}
+ test/Test/Syd/AutodocodecSpec.hs view
@@ -0,0 +1,27 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeApplications #-}++module Test.Syd.AutodocodecSpec (spec) where++import Autodocodec+import Test.Syd+import Test.Syd.Autodocodec++spec :: Spec+spec = do+  describe "pureGoldenYamlSchemaFileViaCodec" $+    it "Example has the same schema as before" $+      pureGoldenYamlSchemaFileVia "test_resources/example.txt" exampleCodec++  describe "pureGoldenYamlSchemaFileViaCodec" $+    it "Int has the same schema as before" $+      pureGoldenYamlSchemaFileViaCodec @Int "test_resources/int.txt"++data Example = Example {exampleInt :: Int, exampleBool :: Bool}++exampleCodec :: JSONCodec Example+exampleCodec =+  object "Example" $+    Example+      <$> requiredField "int" "example int" .= exampleInt+      <*> requiredField "bool" "example bool" .= exampleBool
+ test_resources/example.txt view
@@ -0,0 +1,7 @@+# Example+[37mint[m: # [31mrequired[m+  # example int+  [33m<number>[m # between [32m-9223372036854775808[m and [32m9223372036854775807[m+[37mbool[m: # [31mrequired[m+  # example bool+  [33m<boolean>[m
+ test_resources/int.txt view
@@ -0,0 +1,1 @@+[33m<number>[m # between [32m-9223372036854775808[m and [32m9223372036854775807[m