diff --git a/htest/Test/Ganeti/Types.hs b/htest/Test/Ganeti/Types.hs index 1f3c97470a7ff03398adb82a85af766f77a90319..790f948190884768a10c817a35937d25b291c592 100644 --- a/htest/Test/Ganeti/Types.hs +++ b/htest/Test/Ganeti/Types.hs @@ -107,6 +107,8 @@ $(genArbitrary ''NetworkType) $(genArbitrary ''NICMode) +$(genArbitrary ''FinalizedJobStatus) + -- * Properties prop_AllocPolicy_serialisation :: AllocPolicy -> Property @@ -257,6 +259,18 @@ case_NICMode_pyequiv = do all_hs_codes = sort $ map Types.nICModeToRaw [minBound..maxBound] assertEqual "for NICMode equivalence" all_py_codes all_hs_codes +-- | Test 'FinalizedJobStatus' serialisation. +prop_FinalizedJobStatus_serialisation :: FinalizedJobStatus -> Property +prop_FinalizedJobStatus_serialisation = testSerialisation + +-- | Tests equivalence with Python, based on Constants.hs code. +case_FinalizedJobStatus_pyequiv :: Assertion +case_FinalizedJobStatus_pyequiv = do + let all_py_codes = sort C.jobsFinalized + all_hs_codes = sort $ map Types.finalizedJobStatusToRaw + [minBound..maxBound] + assertEqual "for FinalizedJobStatus equivalence" all_py_codes all_hs_codes + testSuite "Types" [ 'prop_AllocPolicy_serialisation , 'prop_DiskTemplate_serialisation @@ -288,4 +302,6 @@ testSuite "Types" , 'case_NetworkType_pyequiv , 'prop_NICMode_serialisation , 'case_NICMode_pyequiv + , 'prop_FinalizedJobStatus_serialisation + , 'case_FinalizedJobStatus_pyequiv ] diff --git a/htools/Ganeti/Types.hs b/htools/Ganeti/Types.hs index 84e2ab62a2a3505036d56efbe86a0a7b70a5fdb3..90df5656fb9edac5f4be58e7b06d066ee0cede67 100644 --- a/htools/Ganeti/Types.hs +++ b/htools/Ganeti/Types.hs @@ -71,6 +71,8 @@ module Ganeti.Types , networkTypeToRaw , NICMode(..) , nICModeToRaw + , FinalizedJobStatus(..) + , finalizedJobStatusToRaw ) where import qualified Text.JSON as JSON @@ -332,3 +334,11 @@ $(THH.declareSADT "NICMode" , ("NMRouted", 'C.nicModeRouted) ]) $(THH.makeJSONInstance ''NICMode) + +-- | Finalized job status. +$(THH.declareSADT "FinalizedJobStatus" + [ ("JobStatusCanceled", 'C.jobStatusCanceled) + , ("JobStatusSuccessful", 'C.jobStatusSuccess) + , ("JobStatusFailed", 'C.jobStatusError) + ]) +$(THH.makeJSONInstance ''FinalizedJobStatus)