]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/News.hs
Make the News SMS field optional.
[dead/htsn-import.git] / src / TSN / XML / News.hs
index 513bf5c5764a1839c0140fff8344dbad08af28fe..f401d41cb2dbb67d139395a6089c36f09ac9a23d 100644 (file)
@@ -120,7 +120,7 @@ data Message =
     xml_url :: Maybe String,
     xml_teams :: [NewsTeam],
     xml_locations :: [Location],
-    xml_sms :: String,
+    xml_sms :: Maybe String,
     xml_editor :: Maybe String,
     xml_text :: Maybe String,     -- Text and continue seem to show up in pairs,
     xml_continue :: Maybe String, -- either both present or both missing.
@@ -138,7 +138,7 @@ data News =
     db_mid :: MsgId,
     db_sport :: String,
     db_url :: Maybe String,
-    db_sms :: String,
+    db_sms :: Maybe String,
     db_editor :: Maybe String,
     db_text :: Maybe String,
     db_continue :: Maybe String,
@@ -397,7 +397,7 @@ pickle_message =
               (xpElem "url" $ xpOption xpText)
               (xpList pickle_news_team)
               (xpList pickle_location)
-              (xpElem "SMS" xpText)
+              (xpElem "SMS" $ xpOption xpText)
               (xpOption (xpElem "Editor" xpText))
               (xpOption (xpElem "text" xpText))
               pickle_continue
@@ -492,7 +492,10 @@ test_pickle_of_unpickle_is_identity = testGroup "pickle-unpickle tests"
           "test/xml/newsxml.xml",
 
     check "pickle composed with unpickle is the identity (with Editor)"
-          "test/xml/newsxml-with-editor.xml" ]
+          "test/xml/newsxml-with-editor.xml",
+
+    check "pickle composed with unpickle is the identity (empty SMS)"
+          "test/xml/newsxml-empty-sms.xml" ]
   where
     check desc path = testCase desc $ do
       (expected, actual) <- pickle_unpickle pickle_message path
@@ -507,7 +510,10 @@ test_unpickle_succeeds = testGroup "unpickle tests"
           "test/xml/newsxml.xml",
 
     check "unpickling succeeds (with Editor)"
-          "test/xml/newsxml-with-editor.xml" ]
+          "test/xml/newsxml-with-editor.xml",
+
+    check "unpickling succeeds (empty SMS)"
+          "test/xml/newsxml-empty-sms.xml" ]
   where
     check desc path = testCase desc $ do
       actual <- unpickleable path pickle_message
@@ -523,6 +529,10 @@ test_on_delete_cascade = testGroup "cascading delete tests"
   [ check "deleting news deletes its children"
           "test/xml/newsxml.xml"
           4 -- 2 news_teams and 2 news_locations that should remain.
+    ,
+    check "deleting news deletes its children (empty SMS)"
+          "test/xml/newsxml-empty-sms.xml"
+          4 -- 2 news_teams and 2 news_locations
   ]
   where
     check desc path expected = testCase desc $ do