genvalidity-appendful 0.0.0.0 → 0.1.0.0
raw patch · 7 files changed
+84/−17 lines, 7 filesdep +autodocodecdep +autodocodec-yamldep +genvalidity-sydtestdep −genvalidity-hspecdep −genvalidity-hspec-aesondep −hspecPVP ok
version bump matches the API change (PVP)
Dependencies added: autodocodec, autodocodec-yaml, genvalidity-sydtest, genvalidity-sydtest-aeson, safe-coloured-text, sydtest
Dependencies removed: genvalidity-hspec, genvalidity-hspec-aeson, hspec
API changes (from Hackage documentation)
Files
- genvalidity-appendful.cabal +15/−5
- test/Data/Appendful/CollectionSpec.hs +34/−11
- test/Spec.hs +1/−1
- test_resources/collection/client.txt +11/−0
- test_resources/collection/request.txt +10/−0
- test_resources/collection/response.txt +11/−0
- test_resources/collection/server.txt +2/−0
genvalidity-appendful.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.7.+-- This file has been generated from package.yaml by hpack version 0.35.0. -- -- see: https://github.com/sol/hpack name: genvalidity-appendful-version: 0.0.0.0+version: 0.1.0.0 description: Generators for ppend-only cooperative agreement homepage: https://github.com/NorfairKing/appendful#readme bug-reports: https://github.com/NorfairKing/appendful/issues@@ -14,6 +14,11 @@ copyright: Copyright: (c) 2020-2022 Tom Sydney Kerckhove license: MIT build-type: Simple+extra-source-files:+ test_resources/collection/client.txt+ test_resources/collection/request.txt+ test_resources/collection/response.txt+ test_resources/collection/server.txt source-repository head type: git@@ -46,19 +51,24 @@ hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-tool-depends:+ sydtest-discover:sydtest-discover build-depends: QuickCheck , appendful+ , autodocodec+ , autodocodec-yaml , base >=4.7 && <5 , containers , genvalidity-appendful- , genvalidity-hspec- , genvalidity-hspec-aeson+ , genvalidity-sydtest+ , genvalidity-sydtest-aeson , genvalidity-uuid- , hspec , mtl , pretty-show , random+ , safe-coloured-text+ , sydtest , time , uuid default-language: Haskell2010
test/Data/Appendful/CollectionSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RankNTypes #-}@@ -9,31 +10,53 @@ ) where +import Autodocodec+import Autodocodec.Yaml import Control.Monad.State import Data.Appendful.Collection+import Data.Data import Data.GenValidity.Appendful.Collection () import Data.GenValidity.UUID () import Data.List import qualified Data.Map.Strict as M import Data.UUID+import Data.Word import GHC.Generics (Generic) import System.Random-import Test.Hspec-import Test.Validity-import Test.Validity.Aeson+import Test.Syd+import Test.Syd.Validity+import Test.Syd.Validity.Aeson+import Test.Syd.Validity.Utils+import Text.Colour {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} spec :: Spec spec = do- genValidSpec @(ClientStore ClientId Int Int)- jsonSpec @(ClientStore ClientId Int Int)- genValidSpec @(SyncRequest ClientId Int Int)- jsonSpec @(SyncRequest ClientId Int Int)- genValidSpec @(SyncResponse ClientId Int Int)- jsonSpec @(SyncResponse ClientId Int Int)- genValidSpec @(ServerStore Int Int)- jsonSpec @(ServerStore Int Int)+ let yamlSchemaSpec :: forall a. (Typeable a, GenValid a, HasCodec a) => FilePath -> Spec+ yamlSchemaSpec filePath = do+ it ("outputs the same schema as before for " <> nameOf @a) $+ pureGoldenTextFile+ ("test_resources/collection/" <> filePath <> ".txt")+ (renderChunksText With24BitColours $ schemaChunksViaCodec @a)++ describe "ClientStore" $ do+ genValidSpec @(ClientStore ClientId Word8 Word8)+ jsonSpec @(ClientStore ClientId Word8 Word8)+ yamlSchemaSpec @(ClientStore ClientId Word8 Word8) "client"+ describe "SyncRequest" $ do+ genValidSpec @(SyncRequest ClientId Word8 Word8)+ jsonSpec @(SyncRequest ClientId Word8 Word8)+ yamlSchemaSpec @(SyncRequest ClientId Word8 Word8) "request"+ describe "SyncResponse" $ do+ genValidSpec @(SyncResponse ClientId Word8 Word8)+ jsonSpec @(SyncResponse ClientId Word8 Word8)+ yamlSchemaSpec @(SyncResponse ClientId Word8 Word8) "response"+ describe "ServerStore" $ do+ genValidSpec @(ServerStore Word8 Word8)+ jsonSpec @(ServerStore Word8 Word8)+ yamlSchemaSpec @(ServerStore Word8 Word8) "server"+ describe "emptyStore" $ it "is valid" $ shouldBeValid (emptyClientStore @Int @Int @Int) describe "storeSize" $ do it "does not crash" $ producesValid (storeSize @Int @Int @Int)
test/Spec.hs view
@@ -1,1 +1,1 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}+{-# OPTIONS_GHC -F -pgmF sydtest-discover #-}
+ test_resources/collection/client.txt view
@@ -0,0 +1,11 @@+# ClientStore+[37madded[m: # [34moptional[m+ # default: [35m{}[m+ # added items+ [37m<key>[m: + [33m<number>[m # between [32m0[m and [32m255[m+[37msynced[m: # [34moptional[m+ # default: [35m{}[m+ # synced items+ [37m<key>[m: + [33m<number>[m # between [32m0[m and [32m255[m
+ test_resources/collection/request.txt view
@@ -0,0 +1,10 @@+# SyncRequest+[37madded[m: # [34moptional[m+ # default: [35m{}[m+ # new items+ [37m<key>[m: + [33m<number>[m # between [32m0[m and [32m255[m+[37mmax-synced[m: # [34moptional[m+ # largest synced value+ # [32mor null[m+ [33m<number>[m # between [32m0[m and [32m255[m
+ test_resources/collection/response.txt view
@@ -0,0 +1,11 @@+# SyncResponse+[37mclient-added[m: # [34moptional[m+ # default: [35m{}[m+ # items added by the client+ [37m<key>[m: + [33m<number>[m # between [32m0[m and [32m255[m+[37mserver-added[m: # [34moptional[m+ # default: [35m{}[m+ # items added by the server+ [37m<key>[m: + [33m<number>[m # between [32m0[m and [32m255[m
+ test_resources/collection/server.txt view
@@ -0,0 +1,2 @@+[37m<key>[m: + [33m<number>[m # between [32m0[m and [32m255[m