diff --git a/default.nix b/default.nix index 0a05de4..5c9eefe 100644 --- a/default.nix +++ b/default.nix @@ -1,15 +1,15 @@ -{ mkDerivation, aeson, base, bytestring, hspec, hspec-discover, lib -, QuickCheck, quickcheck-instances, text, unordered-containers -, yaml +{ mkDerivation, aeson, base, bytestring, hspec, hspec-discover +, HsYAML, HsYAML-aeson, lib, QuickCheck, quickcheck-instances, text +, unordered-containers }: mkDerivation { pname = "richenv"; - version = "0.1.0.1"; + version = "0.1.0.2"; src = ./.; libraryHaskellDepends = [ aeson base text unordered-containers ]; testHaskellDepends = [ - aeson base bytestring hspec QuickCheck quickcheck-instances text - unordered-containers yaml + aeson base bytestring hspec HsYAML HsYAML-aeson QuickCheck + quickcheck-instances text unordered-containers ]; testToolDepends = [ hspec-discover ]; homepage = "https://github.com/DavSanchez/richenv"; diff --git a/richenv.cabal b/richenv.cabal index dc65893..5a6ec0d 100644 --- a/richenv.cabal +++ b/richenv.cabal @@ -21,7 +21,7 @@ name: richenv -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.1.0.1 +version: 0.1.0.2 -- A short (one-line) description of the package. synopsis: Rich environment variable setup for Haskell @@ -160,10 +160,11 @@ test-suite richenv-test , aeson , bytestring >=0.11 && <0.13 , hspec >=2.10 && <2.12 + , HsYAML + , HsYAML-aeson , QuickCheck >=2.14 && <2.15 , quickcheck-instances >=0.3.29 && <0.4 , richenv - , yaml >=0.11 && <0.12 -- , process >=1.6 && <1.7 build-tool-depends: hspec-discover:hspec-discover diff --git a/test/RichEnvSpec.hs b/test/RichEnvSpec.hs index 724877e..f683433 100644 --- a/test/RichEnvSpec.hs +++ b/test/RichEnvSpec.hs @@ -1,14 +1,14 @@ module RichEnvSpec (spec) where import ArbitraryInstances () -import Control.Exception (displayException) import Data.Aeson qualified as JSON import Data.ByteString qualified as B import Data.ByteString.Char8 qualified as C8 import Data.HashMap.Strict qualified as HM import Data.List (sort) import Data.Text qualified as T -import Data.Yaml qualified as Yaml +import Data.YAML (Pos) +import Data.YAML.Aeson qualified as Yaml import GHC.Generics (Generic) import RichEnv (clearEnvironment, setRichEnvFromCurrent, toEnvListFromCurrent) import RichEnv.Types (Environment, Mappings (Mappings), Prefixes (Prefixes), RichEnv (..), Values (Values), defaultRichEnv, fromEnvironment, toEnvironment) @@ -75,9 +75,9 @@ spec = describe "RichEnv ops" $ do context "working with YAML" $ it "parses a YAML file into expected results" $ do clearEnv setTestEnv fileTestsBaseEnv - let res = Yaml.decodeEither' yamlTestCase :: Either Yaml.ParseException TestType + let res = Yaml.decode1Strict yamlTestCase case res of - Left err -> fail $ show err + Left err -> fail $ "Parse failed. State: " <> show err Right actual -> testEnvList fileTestsCaseExpected (environ actual) context "working with JSON" $ it "parses a JSON file into expected results" $ do @@ -90,10 +90,11 @@ spec = describe "RichEnv ops" $ do context "invariants" $ do prop "parsing YAML from and to a RichEnv should end in the original value" $ \re -> do - let yaml = Yaml.encode re - res = Yaml.decodeEither' yaml :: Either Yaml.ParseException RichEnv + let yaml = Yaml.encode1Strict re + C8.writeFile "./testcase.yaml" yaml + let res = Yaml.decode1Strict yaml :: Either (Pos, String) RichEnv in case res of - Left err -> fail $ displayException err + Left err -> fail $ "Parse failed. State: " <> show err Right actual -> do actual `shouldBe` re prop "parsing JSON from and to a RichEnv should end in the original value" $ \re -> do