Skip to content

Commit

Permalink
test: replace yaml dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
DavSanchez committed May 20, 2024
1 parent 28ebf6b commit 6b8a7f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
5 changes: 3 additions & 2 deletions richenv.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
15 changes: 8 additions & 7 deletions test/RichEnvSpec.hs
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6b8a7f7

Please sign in to comment.