mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
tests: custom Arbitrary BuildResult without Just mempty errorMessage
This commit is contained in:
parent
cc931dde1e
commit
a7fbcf7a02
@ -10,7 +10,6 @@ import Test.Hspec (Expectation, Spec, describe, it, parallel, shouldBe)
|
||||
import Test.Hspec.QuickCheck (prop)
|
||||
import Test.QuickCheck (Gen, arbitrary, forAll, suchThat)
|
||||
|
||||
import qualified System.Nix.Build
|
||||
import qualified System.Nix.Hash
|
||||
|
||||
import System.Nix.Arbitrary ()
|
||||
@ -75,9 +74,7 @@ spec = parallel $ do
|
||||
prop "mapS" $ roundtripS (mapS (int @Int) byteString)
|
||||
|
||||
describe "Complex" $ do
|
||||
prop "BuildResult"
|
||||
$ forAll (arbitrary `suchThat` ((/= Just "") . System.Nix.Build.errorMessage))
|
||||
$ roundtripS buildResult
|
||||
prop "BuildResult" $ roundtripS buildResult
|
||||
|
||||
prop "StorePath" $
|
||||
roundtripSReader @StoreDir storePath
|
||||
|
@ -13,7 +13,6 @@ import Test.QuickCheck (arbitrary, forAll, suchThat)
|
||||
|
||||
import qualified Data.Either
|
||||
import qualified Data.HashSet
|
||||
import qualified System.Nix.Build
|
||||
|
||||
import System.Nix.Arbitrary ()
|
||||
import System.Nix.Build (BuildMode(..), BuildResult, BuildStatus(..))
|
||||
@ -77,9 +76,7 @@ spec = parallel $ do
|
||||
prop "Text" $ roundtripS @Text
|
||||
prop "BuildMode" $ roundtripS @BuildMode
|
||||
prop "BuildStatus" $ roundtripS @BuildStatus
|
||||
it "BuildResult" $
|
||||
forAll (arbitrary `suchThat` ((/= Just "") . System.Nix.Build.errorMessage))
|
||||
$ roundtripS @BuildResult
|
||||
prop "BuildResult" $ roundtripS @BuildResult
|
||||
|
||||
prop "ProtoVersion" $ roundtripS @ProtoVersion
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
module System.Nix.Arbitrary.Build where
|
||||
|
||||
import Data.Text.Arbitrary ()
|
||||
import Test.QuickCheck (Arbitrary(..))
|
||||
import Test.QuickCheck (Arbitrary(..), suchThat)
|
||||
import Test.QuickCheck.Arbitrary.Generic (GenericArbitrary(..))
|
||||
import System.Nix.Arbitrary.UTCTime ()
|
||||
|
||||
@ -16,5 +16,14 @@ deriving via GenericArbitrary BuildMode
|
||||
deriving via GenericArbitrary BuildStatus
|
||||
instance Arbitrary BuildStatus
|
||||
|
||||
deriving via GenericArbitrary BuildResult
|
||||
instance Arbitrary BuildResult
|
||||
instance Arbitrary BuildResult where
|
||||
arbitrary = do
|
||||
status <- arbitrary
|
||||
-- we encode empty errorMessage as Nothing
|
||||
errorMessage <- arbitrary `suchThat` (/= Just mempty)
|
||||
timesBuilt <- arbitrary
|
||||
isNonDeterministic <- arbitrary
|
||||
startTime <- arbitrary
|
||||
stopTime <- arbitrary
|
||||
|
||||
pure $ BuildResult{..}
|
||||
|
Loading…
Reference in New Issue
Block a user