avro 0.6.0.0 → 0.6.0.1
raw patch · 4 files changed
+78/−4 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- avro.cabal +2/−1
- src/Data/Avro/Deriving/NormSchema.hs +3/−0
- test/Avro/Data/TwoBits.hs +64/−0
- test/Avro/NormSchemaSpec.hs +9/−3
avro.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: avro-version: 0.6.0.0+version: 0.6.0.1 synopsis: Avro serialization support for Haskell description: Avro serialization and deserialization support for Haskell category: Data@@ -206,6 +206,7 @@ Avro.Data.Maybe Avro.Data.Recursive Avro.Data.Reused+ Avro.Data.TwoBits Avro.Data.Unions Avro.Decode.ContainerSpec Avro.Decode.RawBlocksSpec
src/Data/Avro/Deriving/NormSchema.hs view
@@ -67,6 +67,9 @@ r@Fixed{name = tn} -> do modify' (M.insert tn (NamedType tn)) pure r+ r@Enum{name = tn} -> do+ modify' (M.insert tn (NamedType tn))+ pure r s -> pure s where setType fld t = fld { fldType = t}
+ test/Avro/Data/TwoBits.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE NumDecimals #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE StrictData #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TupleSections #-}+{-# LANGUAGE TypeApplications #-}++module Avro.Data.TwoBits+where++import Data.Avro.Deriving (deriveAvroFromByteString, r)++import Hedgehog+import Hedgehog.Gen as Gen+import Hedgehog.Range as Range++import qualified Data.ByteString.Lazy as LBS++twoBits'rawSchema :: LBS.ByteString+twoBits'rawSchema = [r|+{+ "type": "record",+ "name": "TwoBits",+ "fields": [+ { "name": "bit0",+ "type": {+ "type": "enum",+ "name": "Bit",+ "symbols": [ "Zero", "One"]+ }+ },+ { "name": "bit1",+ "type": "Bit"+ }+ ]+}+|]+++deriveAvroFromByteString [r|+{+ "type": "record",+ "name": "TwoBits",+ "fields": [+ { "name": "bit0",+ "type": {+ "type": "enum",+ "name": "Bit",+ "symbols": [ "Zero", "One"]+ }+ },+ { "name": "bit1",+ "type": "Bit"+ }+ ]+}+|]
test/Avro/NormSchemaSpec.hs view
@@ -1,14 +1,16 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-} module Avro.NormSchemaSpec where import Data.Avro.Schema.Schema (Schema (..), fields, fldType, mkUnion) import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.Set as S--import Avro.Data.Karma-import Avro.Data.Reused+import qualified Data.Aeson as Aeson+import Avro.Data.Karma+import Avro.Data.Reused+import Avro.Data.TwoBits import Test.Hspec @@ -21,3 +23,7 @@ it "should normalise schemas from unions" $ fldType <$> fields schema'Curse `shouldBe` [mkUnion (Null :| [schema'Geo])]++ it "should serialise reused schema correctly" $+ let Just expected = Aeson.encode <$> Aeson.decode @Schema twoBits'rawSchema+ in Aeson.encode schema'TwoBits `shouldBe` expected