Revision 3cbd5808 test/hs/Test/Ganeti/Types.hs

b/test/hs/Test/Ganeti/Types.hs
30 30
  ( testTypes
31 31
  , AllocPolicy(..)
32 32
  , DiskTemplate(..)
33
  , allDiskTemplates
33 34
  , InstanceStatus(..)
34 35
  , NonEmpty(..)
35 36
  , Hypervisor(..)
36 37
  , JobId(..)
37 38
  ) where
38 39

  
39
import Data.List (sort)
40
import Data.List (delete, sort)
40 41
import Test.QuickCheck as QuickCheck hiding (Result)
41 42
import Test.HUnit
42 43
import qualified Text.JSON as J
......
78 79

  
79 80
$(genArbitrary ''AllocPolicy)
80 81

  
81
$(genArbitrary ''DiskTemplate)
82
-- | Valid disk templates (depending on configure options).
83
allDiskTemplates :: [DiskTemplate]
84
allDiskTemplates =
85
  let all_vals = [minBound..maxBound]::[DiskTemplate]
86
      sel1 = if C.enableFileStorage
87
               then all_vals
88
               else delete DTFile all_vals
89
      sel2 = if C.enableSharedFileStorage
90
               then sel1
91
               else delete DTSharedFile sel1
92
  in sel2
93

  
94
-- | Custom 'Arbitrary' instance for 'DiskTemplate', which needs to
95
-- handle the case of file storage being disabled at configure time.
96
instance Arbitrary DiskTemplate where
97
  arbitrary = elements allDiskTemplates
82 98

  
83 99
$(genArbitrary ''InstanceStatus)
84 100

  
......
96 112

  
97 113
$(genArbitrary ''OobCommand)
98 114

  
99
$(genArbitrary ''StorageType)
115
-- | Valid storage types.
116
allStorageTypes :: [StorageType]
117
allStorageTypes =
118
  let all_vals = [minBound..maxBound]::[StorageType]
119
  in if C.enableFileStorage
120
       then all_vals
121
       else delete StorageFile all_vals
122

  
123
-- | Custom 'Arbitrary' instance for 'StorageType', which needs to
124
-- handle the case of file storage being disabled at configure time.
125
instance Arbitrary StorageType where
126
  arbitrary = elements allStorageTypes
100 127

  
101 128
$(genArbitrary ''NodeEvacMode)
102 129

  

Also available in: Unified diff