From be5feec1be2445eaa6d361c755977546a9352881 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Tue, 16 Aug 2016 19:34:41 +0200 Subject: [PATCH] Refactored. --- test/ENABLE_POP3.bats | 68 ++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/test/ENABLE_POP3.bats b/test/ENABLE_POP3.bats index ebd549df..9fba601c 100644 --- a/test/ENABLE_POP3.bats +++ b/test/ENABLE_POP3.bats @@ -1,30 +1,52 @@ -if [ "$ENABLE_POP3" = 1 ]; then +#################################################################################################### +# +# ENABLE_POP3=1 +# +#################################################################################################### - @test "checking pop: process is running" { - run docker exec mail /bin/bash -c "ps aux | grep 'dovecot/pop'" - [ "$status" -eq 0 ] - } +@test "checking pop: process is running" { + if [ "$ENABLE_POP3" != 1 ]; then + skip + fi + run docker exec mail /bin/bash -c "ps aux | grep 'dovecot/pop'" + [ "$status" -eq 0 ] +} - @test "checking pop: server responds on port 110" { - run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'" - [ "$status" -eq 0 ] - } +@test "checking pop: server responds on port 110" { + if [ "$ENABLE_POP3" != 1 ]; then + skip + fi + run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'" + [ "$status" -eq 0 ] +} - @test "checking pop: authentication works" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt" - [ "$status" -eq 0 ] - } +@test "checking pop: authentication works" { + if [ "$ENABLE_POP3" != 1 ]; then + skip + fi + run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt" + [ "$status" -eq 0 ] +} -else skip #################################################################################################### +#################################################################################################### +# +# ENABLE_POP3!=1 +# +#################################################################################################### - @test "checking process: process is not running" { - run docker exec mail /bin/bash -c "ps aux | grep -v grep | grep 'dovecot/pop'" - [ "$status" -eq 1 ] - } +@test "checking process: process is not running" { + if [ "$ENABLE_POP3" = 1 ]; then + skip + fi + run docker exec mail /bin/bash -c "ps aux | grep -v grep | grep 'dovecot/pop'" + [ "$status" -eq 1 ] +} - @test "checking pop: server does not respond on port 110" { - run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110" - [ "$status" -eq 1 ] - } +@test "checking pop: server does not respond on port 110" { + if [ "$ENABLE_POP3" = 1 ]; then + skip + fi + run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110" + [ "$status" -eq 1 ] +} -fi