File tree Expand file tree Collapse file tree 4 files changed +23
-8
lines changed
hnix-store-core/src/System/Nix
hnix-store-remote/tests-io
hnix-store-tests/src/System/Nix/Arbitrary Expand file tree Collapse file tree 4 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import Data.ByteString (ByteString)
1414import Data.HashSet (HashSet )
1515import System.Nix.Hash (BaseEncoding (Base16 ), NamedAlgo (algoName ))
1616import System.Nix.Store.Types (FileIngestionMethod (.. ), PathFilter , RepairMode )
17- import System.Nix.StorePath (StoreDir , StorePath ( StorePath ) , StorePathName )
17+ import System.Nix.StorePath (StoreDir , StorePath , StorePathName )
1818
1919import qualified Crypto.Hash
2020import qualified Data.ByteString.Char8
@@ -35,7 +35,8 @@ makeStorePath
3535 -> Digest hashAlgo
3636 -> StorePathName
3737 -> StorePath
38- makeStorePath storeDir ty h nm = StorePath storeHash nm
38+ makeStorePath storeDir ty h nm =
39+ System.Nix.StorePath. unsafeMakeStorePath storeHash nm
3940 where
4041 storeHash = System.Nix.StorePath. mkStorePathHashPart @ hashAlgo s
4142 s =
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ module System.Nix.StorePath
1010 StoreDir (.. )
1111 , HasStoreDir (.. )
1212 , getStoreDir
13- , StorePath (.. )
13+ , StorePath
14+ , storePathHash
15+ , storePathName
1416 , StorePathName
1517 , unStorePathName
1618 , StorePathHashPart
@@ -31,6 +33,8 @@ module System.Nix.StorePath
3133 parsePath
3234 , parsePathFromText
3335 , pathParser
36+ -- * Utilities for tests
37+ , unsafeMakeStorePath
3438 ) where
3539
3640import Control.Monad.Reader.Class (MonadReader , asks )
@@ -299,3 +303,13 @@ pathParser expectedRoot = do
299303 (fail . show )
300304 pure
301305 (StorePath <$> hashPart <*> name)
306+
307+ -- * Utilities for tests
308+
309+ -- | Paths rarely need to be constructed directly.
310+ -- Prefer @parsePath@ or @parsePathFromText@
311+ unsafeMakeStorePath
312+ :: StorePathHashPart
313+ -> StorePathName
314+ -> StorePath
315+ unsafeMakeStorePath = StorePath
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ dummy = do
174174invalidPath :: StorePath
175175invalidPath =
176176 let name = Data.Either. fromRight (error " impossible" ) $ makeStorePathName " invalid"
177- in StorePath (mkStorePathHashPart @ SHA256 " invalid" ) name
177+ in unsafeMakeStorePath (mkStorePathHashPart @ SHA256 " invalid" ) name
178178
179179withBuilder :: (StorePath -> MonadStore a ) -> MonadStore a
180180withBuilder action = do
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ import Crypto.Hash (SHA256)
1111import qualified Data.ByteString.Char8
1212import qualified Data.Text
1313import System.Nix.StorePath (StoreDir (.. )
14- , StorePath ( .. )
15- , StorePathName ( .. )
16- , StorePathHashPart ( .. )
14+ , StorePath
15+ , StorePathName
16+ , StorePathHashPart
1717 )
1818import qualified System.Nix.StorePath
1919
@@ -27,7 +27,7 @@ instance Arbitrary StoreDir where
2727
2828instance Arbitrary StorePath where
2929 arbitrary =
30- liftA2 StorePath
30+ liftA2 System.Nix. StorePath. unsafeMakeStorePath
3131 arbitrary
3232 arbitrary
3333
You can’t perform that action at this time.
0 commit comments