diff --git a/htest/Test/Ganeti/Objects.hs b/htest/Test/Ganeti/Objects.hs index aa4e16a0cf9ecca5e7522d6820cfe809c9011600..941e71c6e71db8e049f2601f973a99bd1c6df044 100644 --- a/htest/Test/Ganeti/Objects.hs +++ b/htest/Test/Ganeti/Objects.hs @@ -59,8 +59,6 @@ instance Arbitrary Node where <*> arbitrary <*> arbitrary <*> getFQDN <*> arbitrary <*> (Set.fromList <$> genTags) -$(genArbitrary ''FileDriver) - $(genArbitrary ''BlockDriver) $(genArbitrary ''DiskMode) diff --git a/htest/Test/Ganeti/Types.hs b/htest/Test/Ganeti/Types.hs index e3774dbcc0b834b8900bf705088d44d9ec32046c..f345437a45d8d90766ec7c014e0746d308f87ace 100644 --- a/htest/Test/Ganeti/Types.hs +++ b/htest/Test/Ganeti/Types.hs @@ -56,6 +56,11 @@ instance (Arbitrary a, Ord a, Num a, Show a) => (QuickCheck.Positive i) <- arbitrary Types.mkPositive i +instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where + arbitrary = do + QuickCheck.NonEmpty lst <- arbitrary + Types.mkNonEmpty lst + $(genArbitrary ''AllocPolicy) $(genArbitrary ''DiskTemplate) @@ -78,10 +83,7 @@ $(genArbitrary ''StorageType) $(genArbitrary ''NodeEvacMode) -instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where - arbitrary = do - QuickCheck.NonEmpty lst <- arbitrary - Types.mkNonEmpty lst +$(genArbitrary ''FileDriver) -- * Properties @@ -176,6 +178,10 @@ prop_StorageType_serialisation = testSerialisation prop_NodeEvacMode_serialisation :: NodeEvacMode -> Property prop_NodeEvacMode_serialisation = testSerialisation +-- | Test 'FileDriver' serialisation. +prop_FileDriver_serialisation :: FileDriver -> Property +prop_FileDriver_serialisation = testSerialisation + testSuite "Types" [ 'prop_AllocPolicy_serialisation , 'prop_DiskTemplate_serialisation @@ -195,4 +201,5 @@ testSuite "Types" , 'prop_OobCommand_serialisation , 'prop_StorageType_serialisation , 'prop_NodeEvacMode_serialisation + , 'prop_FileDriver_serialisation ] diff --git a/htools/Ganeti/Objects.hs b/htools/Ganeti/Objects.hs index 1b98db35dcdde8b01e050e95062975b7fffd0743..f591bb98891a7c073e21d18ae754eeb14f092a08 100644 --- a/htools/Ganeti/Objects.hs +++ b/htools/Ganeti/Objects.hs @@ -202,13 +202,6 @@ $(declareSADT "DiskType" ]) $(makeJSONInstance ''DiskType) --- | The file driver type. -$(declareSADT "FileDriver" - [ ("FileLoop", 'C.fdLoop) - , ("FileBlktap", 'C.fdBlktap) - ]) -$(makeJSONInstance ''FileDriver) - -- | The persistent block driver type. Currently only one type is allowed. $(declareSADT "BlockDriver" [ ("BlockDrvManual", 'C.blockdevDriverManual) diff --git a/htools/Ganeti/Types.hs b/htools/Ganeti/Types.hs index 4420d47aa5d1beaa900178381afec00d85d623fc..166b41ce0e4716c13765228861f80311df860623 100644 --- a/htools/Ganeti/Types.hs +++ b/htools/Ganeti/Types.hs @@ -59,6 +59,7 @@ module Ganeti.Types , OobCommand(..) , StorageType(..) , NodeEvacMode(..) + , FileDriver(..) ) where import qualified Text.JSON as JSON @@ -251,3 +252,10 @@ $(THH.declareSADT "NodeEvacMode" , ("NEvacAll", 'C.iallocatorNevacAll) ]) $(THH.makeJSONInstance ''NodeEvacMode) + +-- | The file driver type. +$(THH.declareSADT "FileDriver" + [ ("FileLoop", 'C.fdLoop) + , ("FileBlktap", 'C.fdBlktap) + ]) +$(THH.makeJSONInstance ''FileDriver)