Revision 89d140d1

b/test/hs/Test/Ganeti/Locking/Allocation.hs
32 32
import qualified Data.Foldable as F
33 33
import qualified Data.Map as M
34 34
import qualified Data.Set as S
35
import qualified Text.JSON as J
35 36

  
36 37
import Test.QuickCheck
37 38

  
......
61 62
              | TestLockA Int
62 63
              | TestCollectionLockB
63 64
              | TestLockB Int
64
              deriving (Ord, Eq, Show)
65
              deriving (Ord, Eq, Show, Read)
65 66

  
66 67
instance Arbitrary TestLock where
67 68
  arbitrary =  frequency [ (1, elements [ TestBigLock
......
300 301
                      (M.lookup lock newOwned)
301 302
             ]
302 303

  
304
instance J.JSON TestOwner where
305
  showJSON (TestOwner x) = J.showJSON x
306
  readJSON = (>>= return . TestOwner) . J.readJSON
303 307

  
308
instance J.JSON TestLock where
309
  showJSON = J.showJSON . show
310
  readJSON = (>>= return . read) . J.readJSON
311

  
312
-- | Verify that for LockAllocation we have readJSON . showJSON = Ok.
313
prop_ReadShow :: Property
314
prop_ReadShow =
315
  forAll (arbitrary :: Gen (LockAllocation TestLock TestOwner)) $ \state ->
316
  J.readJSON (J.showJSON state) ==? J.Ok state
304 317

  
305 318
testSuite "Locking/Allocation"
306 319
 [ 'prop_LocksDisjoint
......
313 326
 , 'prop_BlockNecessary
314 327
 , 'prop_OpportunisticMonotone
315 328
 , 'prop_OpportunisticAnswer
329
 , 'prop_ReadShow
316 330
 ]

Also available in: Unified diff