summaryrefslogtreecommitdiff
path: root/test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-19 16:15:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-19 16:15:39 -0400
commit271bec8c70920322fee13a052df4a9279255e698 (patch)
tree0cd67d713c46945687a9995034d0aa9d3c262e27 /test.hs
parent40fcead8d1378f5d821bdd08e99c3103e5a4b316 (diff)
quickcheck test for transfer info read/write code
Fixed a bug the quickcheck turned up.
Diffstat (limited to 'test.hs')
-rw-r--r--test.hs26
1 files changed, 24 insertions, 2 deletions
diff --git a/test.hs b/test.hs
index 3a8343114..44520b84b 100644
--- a/test.hs
+++ b/test.hs
@@ -1,11 +1,12 @@
{- git-annex test suite
-
- - Copyright 2010,2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE TypeSynonymInstances #-}
import Test.HUnit
import Test.HUnit.Tools
@@ -36,6 +37,7 @@ import qualified Logs.UUIDBased
import qualified Logs.Trust
import qualified Logs.Remote
import qualified Logs.Unused
+import qualified Logs.Transfer
import qualified Remote
import qualified Types.Key
import qualified Types.Messages
@@ -50,7 +52,10 @@ import qualified Utility.Verifiable
import qualified Utility.Process
import qualified Utility.Misc
--- for quickcheck
+import Data.Time.Clock.POSIX
+import System.Posix.Types
+
+-- instances for quickcheck
instance Arbitrary Types.Key.Key where
arbitrary = do
n <- arbitrary
@@ -62,6 +67,22 @@ instance Arbitrary Types.Key.Key where
Types.Key.keyMtime = Nothing
}
+instance Arbitrary Logs.Transfer.TransferInfo where
+ arbitrary = Logs.Transfer.TransferInfo
+ <$> arbitrary
+ <*> arbitrary
+ <*> pure Nothing -- cannot generate a ThreadID
+ <*> pure Nothing -- remote not needed
+ <*> arbitrary
+ <*> arbitrary
+ <*> arbitrary
+
+instance Arbitrary POSIXTime where
+ arbitrary = arbitrarySizedIntegral
+
+instance Arbitrary ProcessID where
+ arbitrary = arbitraryBoundedIntegral
+
main :: IO ()
main = do
prepare
@@ -93,6 +114,7 @@ quickcheck = TestLabel "quickcheck" $ TestList
, qctest "prop_addLog_sane" Logs.UUIDBased.prop_addLog_sane
, qctest "prop_verifiable_sane" Utility.Verifiable.prop_verifiable_sane
, qctest "prop_segment_regressionTest" Utility.Misc.prop_segment_regressionTest
+ , qctest "prop_read_write_transferinfo" Logs.Transfer.prop_read_write_transferinfo
]
blackbox :: Test