From 171025821d2a58e6209d6ca55616879d90c7bc87 Mon Sep 17 00:00:00 2001 From: "Thomas A. Kilian" Date: Wed, 12 Apr 2017 01:36:20 +0200 Subject: [PATCH] added integration tests --- target/bin/addalias | 2 +- target/bin/delalias | 4 ++-- test/tests.bats | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/target/bin/addalias b/target/bin/addalias index a7776d69..f25d05d1 100755 --- a/target/bin/addalias +++ b/target/bin/addalias @@ -24,7 +24,7 @@ grep -qi "^$(escape $EMAIL)[a-zA-Z@.\ ]*$(escape $RECIPIENT)" $DATABASE 2>/dev/n errex "Alias \"$EMAIL $RECIPIENT\" already exists" if grep -qi "^$(escape $EMAIL)" $DATABASE 2>/dev/null; then - sed -i '' "/$EMAIL/s/$/ $RECIPIENT,/" $DATABASE + sed -i "/$EMAIL/s/$/ $RECIPIENT,/" $DATABASE else echo "$EMAIL $RECIPIENT," >> $DATABASE fi diff --git a/target/bin/delalias b/target/bin/delalias index c79d2315..33fed3ec 100755 --- a/target/bin/delalias +++ b/target/bin/delalias @@ -24,7 +24,7 @@ escape() { CNT=$(grep "^$EMAIL" $DATABASE | wc -w | awk '{print $1}') if [[ $CNT -eq 2 ]]; then - sed -i '' "/^$EMAIL/d" $DATABASE + sed -i "/^$EMAIL/d" $DATABASE else - sed -i '' "/^$EMAIL/s/ $RECIPIENT,//g" $DATABASE + sed -i "/^$EMAIL/s/ $RECIPIENT,//g" $DATABASE fi diff --git a/test/tests.bats b/test/tests.bats index 66a7bd3b..859fb376 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -922,6 +922,36 @@ load 'test_helper/bats-assert/load' run value=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org) [ -z "$value" ] } +@test "checking setup.sh: setup.sh alias list" { + run rm ./config/postfix-virtual.cf + run ./setup.sh -c mail alias list + assert_failure +} +@test "checking setup.sh: setup.sh alias add" { + run rm ./config/postfix-virtual.cf + run ./setup.sh -c mail alias add test1@example.org test1@forward.com + assert_success + run ./setup.sh -c mail alias add test1@example.org test2@forward.com + assert_success + run ./setup.sh -c mail alias list + assert_output --partial "test1@example.org test1@forward.com, test2@forward.com," +} +@test "checking setup.sh: setup.sh alias del" { + run rm ./config/postfix-virtual.cf + run ./setup.sh -c mail alias add test1@example.org test1@forward.com + run ./setup.sh -c mail alias add test1@example.org test2@forward.com + run ./setup.sh -c mail alias del test1@example.org test1@forward.com + assert_success + run ./setup.sh -c mail alias list + assert_output --partial "test1@example.org test2@forward.com," + + run ./setup.sh -c mail alias del test1@example.org test2@forward.com + run ./setup.sh -c mail alias del test1@example.org test1@forward.com + assert_success + run ./setup.sh -c mail alias list + assert_output --partial "Empty postfix-virtual.cf" +} + # config @test "checking setup.sh: setup.sh config dkim" {