]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/News.hs
Export a "dtd" function from each XML module and use that instead of hard-coding...
[dead/htsn-import.git] / src / TSN / XML / News.hs
index 2cc9698fb2d2e212fd9d45da74f71d938eca3c90..49be37e932ea3d7414cdb1ab6b9b1d0263243a5d 100644 (file)
@@ -11,6 +11,7 @@
 --   a root element \<message\> that contains an entire news item.
 --
 module TSN.XML.News (
+  dtd,
   pickle_message,
   -- * Tests
   news_tests,
@@ -73,6 +74,12 @@ import Xml (
   unsafe_unpickle )
 
 
+-- | The DTD to which this module corresponds. Used to invoke dbimport.
+--
+dtd :: String
+dtd = "newsxml.dtd"
+
+
 --
 -- DB/XML Data types
 --
@@ -272,7 +279,6 @@ mkPersist defaultCodegenConfig [groundhog|
 -- use our own codegen to peel those off before naming the columns.
 mkPersist tsn_codegen_config [groundhog|
 - entity: News
-  dbName: news
   constructors:
     - name: News
       uniques:
@@ -505,9 +511,11 @@ test_unpickle_succeeds = testGroup "unpickle tests"
 test_on_delete_cascade :: TestTree
 test_on_delete_cascade = testGroup "cascading delete tests"
   [ check "deleting news deletes its children"
-          "test/xml/newsxml.xml" ]
+          "test/xml/newsxml.xml"
+          4 -- 2 news_teams and 2 news_locations that should remain.
+  ]
   where
-    check desc path = testCase desc $ do
+    check desc path expected = testCase desc $ do
       news <- unsafe_unpickle path pickle_message
       let a = undefined :: News
       let b = undefined :: NewsTeam
@@ -530,6 +538,4 @@ test_on_delete_cascade = testGroup "cascading delete tests"
                   count_d <- countAll d
                   count_e <- countAll e
                   return $ count_a + count_b + count_c + count_d + count_e
-      -- There are 2 news_teams and 2 news_locations that should remain.
-      let expected = 4
       actual @?= expected