From: Michael Orlitzky Date: Wed, 22 Jan 2014 22:48:04 +0000 (-0500) Subject: Add a shelltestrunner test suite. X-Git-Tag: 0.0.2~3 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhtsn-import.git;a=commitdiff_plain;h=1f1b0076266ccb665b7d9470f4ed5f2edbc680a4 Add a shelltestrunner test suite. Add a test for duplicate message insertion. Remove an item from the TODO. --- diff --git a/doc/TODO b/doc/TODO index ab96252..7876771 100644 --- 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). diff --git a/htsn-import.cabal b/htsn-import.cabal index 2c6c542..583938d 100644 --- a/htsn-import.cabal +++ b/htsn-import.cabal @@ -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 index 0000000..65a10cc --- /dev/null +++ b/test/ShellTests.hs @@ -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 index 0000000..afce3e5 --- /dev/null +++ b/test/shell/import-duplicates.test @@ -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