remote: add TestStoreConfig

This commit is contained in:
sorki 2023-12-01 11:10:31 +01:00
parent 0ab79e5157
commit ee172f077f
2 changed files with 19 additions and 3 deletions

View File

@ -18,6 +18,9 @@ deriving via GenericArbitrary CheckMode
deriving via GenericArbitrary SubstituteMode
instance Arbitrary SubstituteMode
deriving via GenericArbitrary TestStoreConfig
instance Arbitrary TestStoreConfig
deriving via GenericArbitrary ProtoVersion
instance Arbitrary ProtoVersion

View File

@ -2,15 +2,17 @@
module System.Nix.Store.Remote.Types.StoreConfig
( PreStoreConfig(..)
, StoreConfig(..)
, TestStoreConfig(..)
, HasStoreSocket(..)
) where
import GHC.Generics (Generic)
import Network.Socket (Socket)
import System.Nix.StorePath (HasStoreDir(..), StoreDir)
import System.Nix.Store.Remote.Types.ProtoVersion (HasProtoVersion(..), ProtoVersion)
data PreStoreConfig = PreStoreConfig
{ preStoreConfig_dir :: StoreDir
{ preStoreConfig_dir :: StoreDir
, preStoreConfig_socket :: Socket
}
@ -27,9 +29,9 @@ instance HasStoreSocket PreStoreConfig where
hasStoreSocket = preStoreConfig_socket
data StoreConfig = StoreConfig
{ storeConfig_dir :: StoreDir
{ storeConfig_dir :: StoreDir
, storeConfig_protoVersion :: ProtoVersion
, storeConfig_socket :: Socket
, storeConfig_socket :: Socket
}
instance HasStoreDir StoreDir where
@ -43,3 +45,14 @@ instance HasProtoVersion StoreConfig where
instance HasStoreSocket StoreConfig where
hasStoreSocket = storeConfig_socket
data TestStoreConfig = TestStoreConfig
{ testStoreConfig_dir :: StoreDir
, testStoreConfig_protoVersion :: ProtoVersion
} deriving (Eq, Generic, Ord, Show)
instance HasProtoVersion TestStoreConfig where
hasProtoVersion = testStoreConfig_protoVersion
instance HasStoreDir TestStoreConfig where
hasStoreDir = testStoreConfig_dir