Revision ce93b4a0

b/htest/Test/Ganeti/Objects.hs
41 41
import Test.Ganeti.TestHelper
42 42
import Test.Ganeti.TestCommon
43 43
import Ganeti.Objects as Objects
44
import Ganeti.JSON
44 45

  
45 46
-- * Arbitrary instances
46 47

  
......
82 83
  arbitrary = Disk <$> arbitrary <*> (pure []) <*> arbitrary
83 84
                   <*> arbitrary <*> arbitrary
84 85

  
86
instance Arbitrary PartialBeParams where
87
  -- FIXME: we should generate proper values, >=0, etc., but this is
88
  -- hard for partial ones, where all must be wrapped in a 'Maybe'
89
  arbitrary = PartialBeParams <$> arbitrary <*> arbitrary
90
                              <*> arbitrary <*> arbitrary
91

  
92
instance Arbitrary DiskTemplate where
93
  arbitrary = elements [minBound..maxBound]
94

  
95
instance Arbitrary AdminState where
96
  arbitrary = elements [minBound..maxBound]
97

  
98
instance Arbitrary NICMode where
99
  arbitrary = elements [minBound..maxBound]
100

  
101
instance Arbitrary PartialNicParams where
102
  arbitrary = PartialNicParams <$> arbitrary <*> arbitrary
103

  
104
instance Arbitrary PartialNic where
105
  arbitrary = PartialNic <$> arbitrary <*> arbitrary <*> arbitrary
106

  
107
instance Arbitrary Instance where
108
  arbitrary =
109
    Instance
110
      <$> getFQDN <*> getFQDN <*> getFQDN -- OS name, but...
111
      <*> arbitrary
112
      -- FIXME: add non-empty hvparams when they're a proper type
113
      <*> (pure $ Container Map.empty) <*> arbitrary
114
      -- ... and for OSParams
115
      <*> (pure $ Container Map.empty) <*> arbitrary <*> arbitrary
116
      <*> arbitrary <*> arbitrary <*> arbitrary
117
      -- ts
118
      <*> arbitrary <*> arbitrary
119
      -- uuid
120
      <*> arbitrary
121
      -- serial
122
      <*> arbitrary
123
      -- tags
124
      <*> (Set.fromList <$> genTags)
125

  
85 126
-- * Test properties
86 127

  
87 128
-- | Tests that fillDict behaves correctly
......
111 152
prop_Node_serialisation :: Node -> Property
112 153
prop_Node_serialisation = testSerialisation
113 154

  
155
-- | Check that instance serialisation is idempotent.
156
prop_Inst_serialisation :: Instance -> Property
157
prop_Inst_serialisation = testSerialisation
158

  
114 159
testSuite "Objects"
115 160
  [ 'prop_fillDict
116 161
  , 'prop_Disk_serialisation
162
  , 'prop_Inst_serialisation
117 163
  , 'prop_Node_serialisation
118 164
  ]

Also available in: Unified diff