packages feed

htsn-import-0.1.2: test/shell/import-duplicates.test

#
# 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. There are also 2 weatherxml
# and a newsxml that aren't really supposed to import.
find ./test/xml -maxdepth 1 -name '*.xml' | wc -l
>>>
35
>>>= 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*28
# occurrences of the string 'ERROR'.
./dist/build/htsn-import/htsn-import -c 'shelltest.sqlite3' test/xml/*.xml 2>&1 | grep ERROR | wc -l
>>>
62
>>>= 0

# Finally, clean up after ourselves.
rm -f shelltest.sqlite3
>>>= 0