Skip to content

Commit 285bf42

Browse files
committed
Core: tests: {StorePath,Derivation}: fx Text function type
1 parent 0081cf8 commit 285bf42

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

hnix-store-core/tests/Derivation.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,26 @@ import System.Nix.Derivation ( parseDerivation
1010
, buildDerivation
1111
)
1212

13-
import qualified Data.Attoparsec.Text.Lazy
13+
import qualified Data.Attoparsec.Text
1414
import qualified Data.Text.IO
1515
import qualified Data.Text.Lazy
1616
import qualified Data.Text.Lazy.Builder
1717

1818
processDerivation :: FilePath -> FilePath -> IO ()
1919
processDerivation source dest = do
2020
contents <- Data.Text.IO.readFile source
21-
case
22-
Data.Attoparsec.Text.Lazy.parseOnly
23-
(parseDerivation "/nix/store")
24-
contents
25-
of
26-
Left e -> error e
27-
Right drv ->
21+
either
22+
fail
23+
(\ drv ->
2824
Data.Text.IO.writeFile dest
2925
. Data.Text.Lazy.toStrict
3026
. Data.Text.Lazy.Builder.toLazyText
3127
$ buildDerivation drv
28+
)
29+
(Data.Attoparsec.Text.parseOnly
30+
(parseDerivation "/nix/store")
31+
contents
32+
)
3233

3334
test_derivation :: TestTree
3435
test_derivation =

hnix-store-core/tests/StorePath.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module StorePath where
77

8-
import qualified Data.Attoparsec.Text.Lazy
8+
import qualified Data.Attoparsec.Text
99

1010
import Test.Tasty.QuickCheck
1111

@@ -24,8 +24,8 @@ prop_storePathRoundtrip' x =
2424

2525
prop_storePathRoundtripParser :: NixLike -> NixLike -> Property
2626
prop_storePathRoundtripParser (_ :: NixLike) = \(NixLike x) ->
27-
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
27+
(Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
2828

2929
prop_storePathRoundtripParser' :: StorePath -> Property
3030
prop_storePathRoundtripParser' x =
31-
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
31+
(Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x

0 commit comments

Comments
 (0)