[ -z "$keywords" ] && return 0
- [[ "$file_name" =~ [0-9]{4}\-[0-9]{2}\-[0-9]{2}_.*\.pdf ]] \
- || errlog "file name mismatch pattern" \
- || return $?
-
local title=$(get_title_from_file_name "$file_name")
local date=$(get_date_from_file_name "$file_name")
[ -n "$output" ] \
|| errlog "missing output" \
|| return $?
+ [ -z "$keywords" ] \
+ || [[ "$output" =~ [0-9]{4}\-[0-9]{2}\-[0-9]{2}_.*\.pdf ]] \
+ || errlog "file name mismatch pattern" \
+ || return $?
scanimage --source=DocumentFeeder \
--mode=$mode \
assert_success
}
-@test "should success add keywords" {
+@test "should success scantopdf with keywords" {
+ scanimage() {
+ :
+ }
+ createonepdf() {
+ :
+ }
exiftool() {
:
}
- run add_keywords "2025-07-22_test_word.pdf"
+ run scantopdf "Color" "1" "2025-07-22_test_word.pdf" "keywords"
assert_success
}
+
+@test "should failure add keywords wrong file name" {
+ scanimage() {
+ :
+ }
+
+ run scantopdf "Color" "1" "wrong_name.pdf" "keywords"
+
+ assert_failure
+ assert_line --index 0 "❌ ERROR: file name mismatch pattern"
+}