Safe Haskell | None |
---|
Unittests for ganeti-htools.
Synopsis
- arbitraryOpTagsGet :: Gen OpCode
- arbitraryOpTagsSet :: Gen OpCode
- arbitraryOpTagsDel :: Gen OpCode
- arbitraryDataCollector :: Gen (GenericContainer String Bool)
- arbitraryDataCollectorInterval :: Gen (Maybe (GenericContainer String Int))
- emptyJSObject :: JSObject JSValue
- emptyMUD :: Gen (Maybe (JSObject JSValue))
- genEmptyContainer :: Ord a => Gen (GenericContainer a b)
- genDiskIndices :: Gen [DiskIndex]
- genNodeNames :: Gen [String]
- genNodeNamesNE :: Gen [NonEmptyString]
- genNodeNameNE :: Gen NonEmptyString
- genNameNE :: Gen NonEmptyString
- genNamesNE :: Gen [NonEmptyString]
- genFieldsNE :: Gen [NonEmptyString]
- genMacPrefix :: Gen NonEmptyString
- arbitraryPrivateJSObj :: Gen (JSObject (Private JSValue))
- arbitrarySecretJSObj :: Gen (JSObject (Secret JSValue))
- isJsonError :: Result a -> Bool
- prop_serialization :: OpCode -> Property
- case_AllDefined :: Assertion
- case_py_compat_types :: Assertion
- case_py_compat_fields :: Assertion
- prop_setOpComment :: MetaOpCode -> String -> Property
- prop_mkDiskIndex_fail :: Positive Int -> Property
- case_readRecreateDisks_fail :: Assertion
- case_readDdmOldChanges_fail :: Assertion
- case_readExportTarget_fail :: Assertion
- testOpCodes :: Test
Arbitrary instances
arbitraryOpTagsGet :: Gen OpCode Source #
arbitraryOpTagsSet :: Gen OpCode Source #
arbitraryOpTagsDel :: Gen OpCode Source #
arbitraryDataCollector :: Gen (GenericContainer String Bool) Source #
arbitraryDataCollectorInterval :: Gen (Maybe (GenericContainer String Int)) Source #
Helper functions
emptyJSObject :: JSObject JSValue Source #
Empty JSObject.
genEmptyContainer :: Ord a => Gen (GenericContainer a b) Source #
Generates an empty container.
genDiskIndices :: Gen [DiskIndex] Source #
Generates list of disk indices.
genNodeNames :: Gen [String] Source #
Generates a list of node names.
genNodeNamesNE :: Gen [NonEmptyString] Source #
Generates a list of node names in non-empty string type.
genNodeNameNE :: Gen NonEmptyString Source #
Gets a node name in non-empty type.
genNameNE :: Gen NonEmptyString Source #
Gets a name (non-fqdn) in non-empty type.
genNamesNE :: Gen [NonEmptyString] Source #
Gets a list of names (non-fqdn) in non-empty type.
genFieldsNE :: Gen [NonEmptyString] Source #
Returns a list of non-empty fields.
genMacPrefix :: Gen NonEmptyString Source #
Generate a 3-byte MAC prefix.
arbitraryPrivateJSObj :: Gen (JSObject (Private JSValue)) Source #
JSObject of arbitrary data.
Since JSValue does not implement Arbitrary, I'll simply generate (String, String) objects.
arbitrarySecretJSObj :: Gen (JSObject (Secret JSValue)) Source #
JSObject of arbitrary secret data.
isJsonError :: Result a -> Bool Source #
Small helper to check for a failed JSON deserialisation
Test cases
prop_serialization :: OpCode -> Property Source #
Check that opcode serialization is idempotent.
case_AllDefined :: Assertion Source #
Check that Python and Haskell defined the same opcode list.
case_py_compat_types :: Assertion Source #
Custom HUnit test case that forks a Python process and checks correspondence between Haskell-generated OpCodes and their Python decoded, validated and re-encoded version.
Note that we have a strange beast here: since launching Python is expensive, we don't do this via a usual QuickProperty, since that's slow (I've tested it, and it's indeed quite slow). Rather, we use a single HUnit assertion, and in it we manually use QuickCheck to generate 500 opcodes times the number of defined opcodes, which then we pass in bulk to Python. The drawbacks to this method are two fold: we cannot control the number of generated opcodes, since HUnit assertions don't get access to the test options, and for the same reason we can't run a repeatable seed. We should probably find a better way to do this, for example by having a separately-launched Python process (if not running the tests would be skipped).
case_py_compat_fields :: Assertion Source #
Custom HUnit test case that forks a Python process and checks correspondence between Haskell OpCodes fields and their Python equivalent.
prop_setOpComment :: MetaOpCode -> String -> Property Source #
Checks that setOpComment works correctly.
prop_mkDiskIndex_fail :: Positive Int -> Property Source #
Tests wrong (negative) disk index.
case_readRecreateDisks_fail :: Assertion Source #
Tests a few invalid readRecreateDisks
cases.
case_readDdmOldChanges_fail :: Assertion Source #
Tests a few invalid readDdmOldChanges
cases.
case_readExportTarget_fail :: Assertion Source #
Tests a few invalid readExportTarget
cases.
testOpCodes :: Test Source #