xpWrap )
import TSN.DbImport ( ImportResult(..) )
-import Xml ( pickle_unpickle )
+import Xml ( pickle_unpickle, unpickleable )
data Message =
Message {
verify :: XmlTree -> IO ImportResult
verify xml = do
let root_element = unpickleDoc xpickle xml :: Maybe Message
- case root_element of
- Nothing -> return $ Err "Could not unpickle document in import_generic."
- Just _ -> return $ Info "Heartbeat received."
+ return $ case root_element of
+ Nothing -> ImportFailed "Could not unpickle document in import_generic."
+ Just _ -> ImportSkipped "Heartbeat received. Thump."
-- * Tasty Tests
heartbeat_tests :: TestTree
heartbeat_tests =
testGroup
"Heartbeat tests"
- [ test_pickle_of_unpickle_is_identity ]
+ [ test_pickle_of_unpickle_is_identity,
+ test_unpickle_succeeds ]
+-- | Warning, succeess of this test does not mean that unpickling
+-- succeeded.
test_pickle_of_unpickle_is_identity :: TestTree
test_pickle_of_unpickle_is_identity =
testCase "pickle composed with unpickle is the identity" $ do
let path = "test/xml/Heartbeat.xml"
(expected :: [Message], actual) <- pickle_unpickle "message" path
actual @?= expected
+
+
+test_unpickle_succeeds :: TestTree
+test_unpickle_succeeds =
+ testCase "unpickling succeeds" $ do
+ let path = "test/xml/Heartbeat.xml"
+ actual <- unpickleable path pickle_message
+ let expected = True
+ actual @?= expected