Revision 212b66c3 test/hs/Test/Ganeti/Rpc.hs

b/test/hs/Test/Ganeti/Rpc.hs
42 42
import qualified Ganeti.Objects as Objects
43 43
import qualified Ganeti.Types as Types
44 44
import qualified Ganeti.JSON as JSON
45
import Ganeti.Types
45 46

  
46 47
instance Arbitrary Rpc.RpcCallAllInstancesInfo where
47 48
  arbitrary = Rpc.RpcCallAllInstancesInfo <$> arbitrary
......
50 51
  arbitrary = Rpc.RpcCallInstanceList <$> arbitrary
51 52

  
52 53
instance Arbitrary Rpc.RpcCallNodeInfo where
53
  arbitrary = Rpc.RpcCallNodeInfo <$> arbitrary <*> genHvSpecs <*>
54
                pure Map.empty
54
  arbitrary = Rpc.RpcCallNodeInfo <$> genStorageUnitMap <*> genHvSpecs
55

  
56
genStorageUnit :: Gen StorageUnit
57
genStorageUnit = do
58
  storage_type <- arbitrary
59
  storage_key <- genName
60
  storage_es <- arbitrary
61
  return $ addParamsToStorageUnit storage_es (SURaw storage_type storage_key)
62

  
63
genStorageUnits :: Gen [StorageUnit]
64
genStorageUnits = do
65
  num_storage_units <- choose (0, 5)
66
  vectorOf num_storage_units genStorageUnit
67

  
68
genStorageUnitMap :: Gen (Map.Map String [StorageUnit])
69
genStorageUnitMap = do
70
  num_nodes <- choose (0,5)
71
  node_uuids <- vectorOf num_nodes genName
72
  storage_units_list <- vectorOf num_nodes genStorageUnits
73
  return $ Map.fromList (zip node_uuids storage_units_list)
55 74

  
56 75
-- | Generate hypervisor specifications to be used for the NodeInfo call
57 76
genHvSpecs :: Gen [ (Types.Hypervisor, Objects.HvParams) ]

Also available in: Unified diff