Skip to content

Commit 7dc5c59

Browse files
committed
tests: add/move Test.Hspec.Nix.forceRight from json
1 parent aa94d3c commit 7dc5c59

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

hnix-store-core/tests/Fingerprint.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ forceDecodeB64Pubkey b64EncodedPubkey = let
6969
forceRight :: Either a b -> b
7070
forceRight = \case
7171
Right x -> x
72-
_ -> error "fromRight failed"
72+
_ -> error "forceRight failed"
7373

hnix-store-json/tests/JSONSpec.hs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Data.Aeson (ToJSON, FromJSON, decode, encode)
55
import Data.Default.Class (Default(def))
66
import Test.Hspec (Expectation, Spec, describe, it, shouldBe)
77
import Test.Hspec.QuickCheck (prop)
8-
import Test.Hspec.Nix (roundtrips)
8+
import Test.Hspec.Nix (forceRight, roundtrips)
99

1010
import System.Nix.Arbitrary ()
1111
import System.Nix.JSON ()
@@ -99,11 +99,3 @@ spec = do
9999

100100
it "sampleRealisation1 matches preimage" $
101101
encode sampleRealisation1 `shouldBe` "{\"outPath\":\"5rwxzi7pal3qhpsyfc16gzkh939q1np6-curl-7.82.0.drv\",\"signatures\":[\"SMjnB3mPgXYjXacU+xN24BdzXlAgGAuFnYwPddU3bhjfHBeQus/OimdIPMgR/JMKFPHXORrk7pbjv68vecTEBA==\",\"fW3iEMfyx6IZzGNswD54BjclfkXiYzh0xRXddrXfJ1rp1l8p1xTi9/0g2EibbwLFb6p83cwIJv5KtTGksC54CQ==\"],\"dependentRealisations\":{\"sha256:1b4sb93wp679q4zx9k1ignby1yna3z7c4c2ri3wphylbc2dwsys0!foo\":\"9472ijanf79nlkb5n1yh57s7867p1930-testFixed\"}}"
102-
103-
forceRight
104-
:: Show a
105-
=> Either a b
106-
-> b
107-
forceRight = \case
108-
Right x -> x
109-
Left e -> error $ "fromRight failed: " ++ show e

hnix-store-tests/src/Test/Hspec/Nix.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Test.Hspec.Nix
2-
( roundtrips
2+
( forceRight
3+
, roundtrips
34
) where
45

56
import Test.Hspec (Expectation, shouldBe)
@@ -18,3 +19,11 @@ roundtrips
1819
-> Expectation
1920
roundtrips encode decode x =
2021
decode (encode x) `shouldBe` pure x
22+
23+
forceRight
24+
:: Show a
25+
=> Either a b
26+
-> b
27+
forceRight = \case
28+
Right x -> x
29+
Left e -> error $ "forceRight failed: " ++ show e

0 commit comments

Comments
 (0)