assert_success
assert_line --index 0 "true"
}
+
+@test "should failure createmultipdfs missing basename paramter" {
+ run createmultipdfs
+
+ assert_failure
+ assert_line --index 0 "❌ ERROR: missing basename"
+}
+
+@test "should failure createmultipdfs tiff2pdf fails" {
+ tiff2pdf_exit=1
+
+ run createmultipdfs "base"
+
+ assert_failure
+ assert_line --index 0 "❌ ERROR: could not convert scanned*.tiff to scanned*.pdf"
+}
+
+@test "should failure createmultipdfs rm tiff fails" {
+ rm_exit=1
+
+ run createmultipdfs "base"
+
+ assert_failure
+ assert_line --index 0 "❌ ERROR: could not delete scanned*.tiff"
+}
+
+@test "should success createmutlipdfs" {
+ run createmultipdfs "base"
+
+ assert_success
+}
createmultipdfs()
{
- local trenn=$1
- local basename=$2
+ local basename=$1
local startcount=1
local endcount=1
- local pdf=
command -v tiff2pdf > /dev/null \
|| errlog "command tiff2pdf not found" \
|| return $?
- for i in scanned*.tiff; do
- pdf=${i/.tiff/.pdf}
- tiff2pdf $i -o $pdf \
- || errlog "could not convert $i to $pdf" \
- || return 1
- trenn=$(detectsplit $pdf)
- rm $i
+ [ -n "$basename" ] \
+ || errlog "missing basename" \
+ || return $?
+
+ local pdf=
+ local tiff=
+ for tiff in scanned*.tiff; do
+ pdf=${tiff/.tiff/.pdf}
+ tiff2pdf $tiff -o $pdf \
+ || errlog "could not convert $tiff to $pdf" \
+ || return $?
+ trenn=$(detectsplit $pdf) \
+ || return $?
+ rm $tiff \
+ || errlog "could not delete $tiff" \
+ || return $?
+
if [ "$trenn" == "true" ]; then
- rm $pdf
+ rm $pdf \
+ || errlog "could not delete $pdf" \
+ || return $?
createpdf $startcount $((endcount - 1)) $basename \
- || return 1
+ || return $?
startcount=$((endcount + 1))
fi
+
((endcount++))
done
}