Add query filter tests
[ganeti-local] / htest / Test / Ganeti / OpCodes.hs
index d184d21..93abaf1 100644 (file)
@@ -46,8 +46,7 @@ import qualified Ganeti.OpCodes as OpCodes
 
 -- * Arbitrary instances
 
-instance Arbitrary OpCodes.ReplaceDisksMode where
-  arbitrary = elements [minBound..maxBound]
+$(genArbitrary ''OpCodes.ReplaceDisksMode)
 
 instance Arbitrary OpCodes.DiskIndex where
   arbitrary = choose (0, C.maxDisks - 1) >>= OpCodes.mkDiskIndex
@@ -74,10 +73,7 @@ instance Arbitrary OpCodes.OpCode where
 
 -- | Check that opcode serialization is idempotent.
 prop_serialization :: OpCodes.OpCode -> Property
-prop_serialization op =
-  case J.readJSON (J.showJSON op) of
-    J.Error e -> failTest $ "Cannot deserialise: " ++ e
-    J.Ok op' -> op ==? op'
+prop_serialization = testSerialisation
 
 -- | Check that Python and Haskell defined the same opcode list.
 case_AllDefined :: HUnit.Assertion