add_entry()
{
local entry="kds_s2000w_net"
-
grep --silent "$entry" "$DLLCONFIG" && return 0
echo "$entry" >> "$DLLCONFIG"
echo "add kds_s2000w_net to $DLLCONFIG"
delete_entries()
{
local entry="kds_s2000w_net"
+ grep --silent "$entry" "$DLLCONFIG" || return 0
sed --in-place "/$entry/d" "$DLLCONFIG"
echo "remove $entry from $DLLCONFIG"
}
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