]> gitweb.michael.orlitzky.com - dead/htsn-import.git/commitdiff
Add a shelltestrunner test suite.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 22 Jan 2014 22:48:04 +0000 (17:48 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 22 Jan 2014 22:48:04 +0000 (17:48 -0500)
Add a test for duplicate message insertion.
Remove an item from the TODO.

doc/TODO
htsn-import.cabal
test/ShellTests.hs [new file with mode: 0644]
test/shell/import-duplicates.test [new file with mode: 0644]

index ab96252cf29411678d3c678598fcbedbb63dad52..7876771fd47fa1ac7a7953eda7cd155977c279f4 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -4,6 +4,5 @@
 2. Write a test for test/xml/Odds_XML-long-import.xml once it no
    longer takes 10 minutes to import (Postgres only?).
 
-3. Write a test for the ON DELETE CASCADE behavior.
-
-4. Add a test for inserting duplicate messages.
+3. Write a test for the ON DELETE CASCADE behavior (newsxml, Odds_XML,
+   weatherxml).
index 2c6c5426c672cefc9eaca31da18dd80a03e250a7..583938df6504d0293d297e52bf6764f559e152c5 100644 (file)
@@ -208,6 +208,37 @@ test-suite doctests
     -O2
 
 
+-- These won't work without shelltestrunner installed in your
+-- $PATH. Maybe there is some way to tell Cabal that.
+test-suite shelltests
+  type: exitcode-stdio-1.0
+  hs-source-dirs: test
+  main-is: ShellTests.hs
+
+  build-depends:
+    base                        == 4.*,
+    cmdargs                     >= 0.10.6,
+    configurator                == 0.2.*,
+    directory                   == 1.2.*,
+    filepath                    == 1.3.*,
+    hslogger                    == 1.2.*,
+    htsn-common                 == 0.0.1,
+    hxt                         == 9.3.*,
+    groundhog                   == 0.4.*,
+    groundhog-postgresql        == 0.4.*,
+    groundhog-sqlite            == 0.4.*,
+    groundhog-th                == 0.4.*,
+    MissingH                    == 1.2.*,
+    old-locale                  == 1.0.*,
+    process                     == 1.1.*,
+    tasty                       == 0.7.*,
+    tasty-hunit                 == 0.4.*,
+    time                        == 1.4.*,
+    transformers                == 0.3.*,
+    tuple                       == 0.2.*
+
+
+
 source-repository head
   type: git
   location: http://michael.orlitzky.com/git/htsn-import.git
diff --git a/test/ShellTests.hs b/test/ShellTests.hs
new file mode 100644 (file)
index 0000000..65a10cc
--- /dev/null
@@ -0,0 +1,10 @@
+module Main
+where
+
+import System.Cmd ( system )
+import System.Exit ( exitWith )
+
+main :: IO ()
+main = do
+  result <- system "shelltest test/shell/*.test"
+  exitWith result
diff --git a/test/shell/import-duplicates.test b/test/shell/import-duplicates.test
new file mode 100644 (file)
index 0000000..afce3e5
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# Attempt to import our test XML twice; all attempts after the first
+# should fail.
+#
+
+# First, we remove any leftover mess.
+rm -f shelltest.sqlite3
+>>>= 0
+
+# Now we run the import/migrate silently.
+./dist/build/htsn-import/htsn-import -c 'shelltest.sqlite3' test/xml/*.xml > /dev/null
+>>>= 0
+
+# We note the number of XML files that we have. There's one extra
+# Heartbeat.xml that doesn't really count.
+find ./test/xml -name '*.xml' | wc -l
+>>>
+12
+>>>= 0
+
+# Run the imports again; we should get complaints about the duplicate
+# xml_file_ids. There are 2 errors for each violation, so we expect 2*11
+# occurrences of the string 'ERROR'.
+./dist/build/htsn-import/htsn-import -c 'shelltest.sqlite3' test/xml/*.xml 2>&1 | grep ERROR | wc -l
+>>>
+22
+>>>= 0
+
+# Finally, clean up after ourselves.
+rm -f shelltest.sqlite3
+>>>= 0