]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/Heartbeat.hs
Remove unused BangPatterns pragmas.
[dead/htsn-import.git] / src / TSN / XML / Heartbeat.hs
index c408483f6e2af23e33ade6113be0470a79752a96..bcf906955e9d5c19b8d392a7331aa29118f18445 100644 (file)
@@ -20,7 +20,7 @@ import Text.XML.HXT.Core (
   xpWrap )
 
 import TSN.DbImport ( ImportResult(..) )
-import Xml ( pickle_unpickle )
+import Xml ( pickle_unpickle, unpickleable )
 
 data Message =
   Message {
@@ -52,21 +52,33 @@ instance XmlPickler Message where
 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