From: Bastian Dehn Date: Thu, 16 Jul 2026 18:17:04 +0000 (+0200) Subject: add do nothing no entry do remove X-Git-Tag: v1.1.35^2~3^2~1 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=dbc23704fc2722b3afe5fb0587bcf835e1267dd8;p=sane-kds-s2000w-net.git add do nothing no entry do remove --- diff --git a/src/debian/postinst b/src/debian/postinst index d16fa16..8b84731 100755 --- a/src/debian/postinst +++ b/src/debian/postinst @@ -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" diff --git a/src/debian/postrm b/src/debian/postrm index 1ffbafa..b39374d 100755 --- a/src/debian/postrm +++ b/src/debian/postrm @@ -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" } diff --git a/tests/postrm.bats b/tests/postrm.bats index 8c46de6..6d529ce 100755 --- a/tests/postrm.bats +++ b/tests/postrm.bats @@ -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