Commit 6903fea0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add type for finalised job statuses



For now, we don't need a pending job status type as well, so we'll
delay adding that until later.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent d1ac695f
......@@ -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
]
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment