]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
change check keywords name pattern first
authorBastian Dehn <hhaalo@arcor.de>
Tue, 22 Jul 2025 16:39:50 +0000 (18:39 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 22 Jul 2025 16:42:26 +0000 (18:42 +0200)
src/scanbasic.sh
tests/scanbasic.bats

index 96033d5fc088e855caa466df66f39470865605b9..f31bcbfbeefa425335095e4ce67e8654fc921fa5 100644 (file)
@@ -224,10 +224,6 @@ add_keywords()
 
        [ -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")
 
@@ -260,6 +256,10 @@ scantopdf() {
        [ -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 \
index 8fefc46efa4a5b87497824c1c577f6bcecc43b49..d3bc804a39b00cc9a960f0885fd8839e80dc9cbc 100755 (executable)
@@ -325,12 +325,29 @@ setup() {
        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"
+}