Skip to content

Commit

Permalink
remote: TestStoreConfig no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Dec 10, 2023
1 parent 7b41967 commit 656d4dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions hnix-store-remote/src/System/Nix/Store/Remote/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ deriving via GenericArbitrary CheckMode
deriving via GenericArbitrary SubstituteMode
instance Arbitrary SubstituteMode

deriving via GenericArbitrary TestStoreConfig
instance Arbitrary TestStoreConfig
deriving via GenericArbitrary ProtoStoreConfig
instance Arbitrary ProtoStoreConfig

deriving via GenericArbitrary ProtoVersion
instance Arbitrary ProtoVersion
Expand Down
17 changes: 2 additions & 15 deletions hnix-store-remote/src/System/Nix/Store/Remote/Types/StoreConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
module System.Nix.Store.Remote.Types.StoreConfig
( ProtoStoreConfig(..)
, StoreConfig(..)
, TestStoreConfig(..)
, HasStoreSocket(..)
) where

Expand All @@ -21,7 +20,7 @@ instance HasStoreSocket Socket where
data ProtoStoreConfig = ProtoStoreConfig
{ protoStoreConfig_dir :: StoreDir
, protoStoreConfig_protoVersion :: ProtoVersion
}
} deriving (Eq, Generic, Ord, Show)

instance Default ProtoStoreConfig where
def = ProtoStoreConfig def def
Expand All @@ -36,18 +35,6 @@ instance HasProtoVersion ProtoStoreConfig where
hasProtoVersion = protoStoreConfig_protoVersion

data StoreConfig = StoreConfig
{ storeConfig_dir :: StoreDir
{ storeConfig_dir :: Maybe StoreDir
, storeConfig_socketPath :: FilePath
}

-- TODO: del
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
10 changes: 5 additions & 5 deletions hnix-store-remote/tests/NixSerializerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import System.Nix.Store.Remote.Arbitrary ()
import System.Nix.Store.Remote.Serializer
import System.Nix.Store.Remote.Types.Logger (Logger(..))
import System.Nix.Store.Remote.Types.ProtoVersion (HasProtoVersion(..), ProtoVersion(..))
import System.Nix.Store.Remote.Types.StoreConfig (TestStoreConfig(..))
import System.Nix.Store.Remote.Types.StoreConfig (ProtoStoreConfig(..))
import System.Nix.Store.Remote.Types.StoreRequest (StoreRequest(..))

-- | Test for roundtrip using @NixSerializer@
Expand Down Expand Up @@ -71,7 +71,7 @@ spec = parallel $ do
prop "< 1.28"
$ \sd -> forAll (arbitrary `suchThat` ((< 28) . protoVersion_minor))
$ \pv ->
roundtripSReader @TestStoreConfig buildResult (TestStoreConfig sd pv)
roundtripSReader @ProtoStoreConfig buildResult (ProtoStoreConfig sd pv)
. (\x -> x { buildResultBuiltOutputs = Nothing })
. (\x -> x { buildResultTimesBuilt = Nothing
, buildResultIsNonDeterministic = Nothing
Expand All @@ -81,7 +81,7 @@ spec = parallel $ do
)
prop "= 1.28"
$ \sd ->
roundtripSReader @TestStoreConfig buildResult (TestStoreConfig sd (ProtoVersion 1 28))
roundtripSReader @ProtoStoreConfig buildResult (ProtoStoreConfig sd (ProtoVersion 1 28))
. (\x -> x { buildResultTimesBuilt = Nothing
, buildResultIsNonDeterministic = Nothing
, buildResultStartTime = Nothing
Expand All @@ -91,7 +91,7 @@ spec = parallel $ do
prop "> 1.28"
$ \sd -> forAll (arbitrary `suchThat` ((> 28) . protoVersion_minor))
$ \pv ->
roundtripSReader @TestStoreConfig buildResult (TestStoreConfig sd pv)
roundtripSReader @ProtoStoreConfig buildResult (ProtoStoreConfig sd pv)

prop "StorePath" $
roundtripSReader @StoreDir storePath
Expand Down Expand Up @@ -147,7 +147,7 @@ spec = parallel $ do
prop "StoreRequest"
$ \testStoreConfig ->
forAll (arbitrary `suchThat` (restrictProtoVersion (hasProtoVersion testStoreConfig)))
$ roundtripSReader @TestStoreConfig storeRequest testStoreConfig
$ roundtripSReader @ProtoStoreConfig storeRequest testStoreConfig

describe "StoreReply" $ do
prop "()" $ roundtripS opSuccess
Expand Down

0 comments on commit 656d4dd

Please sign in to comment.