Revision 3e77a36c test/hs/Test/Ganeti/HTools/Types.hs

b/test/hs/Test/Ganeti/HTools/Types.hs
38 38
  ) where
39 39

  
40 40
import Test.QuickCheck hiding (Result)
41
import Test.HUnit
41 42

  
42 43
import Control.Applicative
44
import Data.List (sort)
43 45

  
44 46
import Test.Ganeti.TestHelper
45 47
import Test.Ganeti.TestCommon
......
47 49
import Test.Ganeti.Types ()
48 50

  
49 51
import Ganeti.BasicTypes
52
import qualified Ganeti.Constants as C
50 53
import qualified Ganeti.HTools.Types as Types
51 54

  
52 55
-- * Helpers
......
146 149
                 Ok v' -> v == v'
147 150
    where r = eitherToResult ei
148 151

  
152
-- | Test 'AutoRepairType' ordering is as expected and consistent with Python
153
-- codebase.
154
case_AutoRepairType_sort :: Assertion
155
case_AutoRepairType_sort = do
156
  let expected = [ Types.ArFixStorage
157
                 , Types.ArMigrate
158
                 , Types.ArFailover
159
                 , Types.ArReinstall
160
                 ]
161
      all_hs_raw = map Types.autoRepairTypeToRaw [minBound..maxBound]
162
  assertEqual "Haskell order" expected [minBound..maxBound]
163
  assertEqual "consistent with Python" C.autoRepairAllTypes all_hs_raw
164

  
165
-- | Test 'AutoRepairResult' type is equivalent with Python codebase.
166
case_AutoRepairResult_pyequiv :: Assertion
167
case_AutoRepairResult_pyequiv = do
168
  let all_py_results = sort C.autoRepairAllResults
169
      all_hs_results = sort $
170
                       map Types.autoRepairResultToRaw [minBound..maxBound]
171
  assertEqual "for AutoRepairResult equivalence" all_py_results all_hs_results
172

  
149 173
testSuite "HTools/Types"
150 174
            [ 'prop_ISpec_serialisation
151 175
            , 'prop_IPolicy_serialisation
152 176
            , 'prop_EvacMode_serialisation
153 177
            , 'prop_opToResult
154 178
            , 'prop_eitherToResult
179
            , 'case_AutoRepairType_sort
180
            , 'case_AutoRepairResult_pyequiv
155 181
            ]

Also available in: Unified diff