]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add do nothing no entry do remove
authorBastian Dehn <hhaalo@arcor.de>
Thu, 16 Jul 2026 18:17:04 +0000 (20:17 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 16 Jul 2026 18:17:48 +0000 (20:17 +0200)
src/debian/postinst
src/debian/postrm
tests/postrm.bats

index d16fa168383f1c837f7f5cb7f2aeac356a4e0d24..8b84731f3e88c993d341c205448d838819215400 100755 (executable)
@@ -12,7 +12,6 @@ find_config()
 add_entry()
 {
        local entry="kds_s2000w_net"
-
        grep --silent "$entry" "$DLLCONFIG" && return 0
        echo "$entry" >> "$DLLCONFIG"
        echo "add kds_s2000w_net to $DLLCONFIG"
index 1ffbafaeceb61c76ee66d99cb5d5766dc1c3303c..b39374d641e048e4f0be8665fee07c9e97d15926 100755 (executable)
@@ -12,6 +12,7 @@ find_config()
 delete_entries()
 {
        local entry="kds_s2000w_net"
+       grep --silent "$entry" "$DLLCONFIG" || return 0
        sed --in-place "/$entry/d"  "$DLLCONFIG"
        echo "remove $entry from $DLLCONFIG"
 }
index 8c46de6fa88bc0e3ad84958adef755dc443a7355..6d529ce1652a83d201fe69425330e992b5715ede 100755 (executable)
@@ -40,12 +40,29 @@ teardown() {
        export DLLCONFIG="../build/dllpostrm.conf"
 
        run ../src/debian/postrm
-       run ../src/debian/postrm
+
+       assert_line --index 0 "found ../build/dllpostrm.conf"
+       assert_line --index 1 "remove kds_s2000w_net from ../build/dllpostrm.conf"
+       assert_equal "$(cat ../build/dllpostrm.conf)" ""
+       assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
+
        run ../src/debian/postrm
 
        assert_success
        assert_line --index 0 "found ../build/dllpostrm.conf"
-       assert_line --index 1 "remove kds_s2000w_net from ../build/dllpostrm.conf"
+       assert_equal "$(cat ../build/dllpostrm.conf)" ""
+       assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
+}
+
+@test "do nothing entry kds_s2000w_net not exists from dll.conf {
+       rm -rf ../build/dllpostrm.conf
+       touch ../build/dllpostrm.conf
+       export DLLCONFIG="../build/dllpostrm.conf"
+
+       run ../src/debian/postrm
+
+       assert_success
+       assert_output "found ../build/dllpostrm.conf"
        assert_equal "$(cat ../build/dllpostrm.conf)" ""
        assert_equal "$(cat ../build/dllpostrm.conf | wc --lines)" "0"
 }
\ No newline at end of file