From d1e6c1315674d46107f84ce084266bc7349647c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20K=C5=82os?= Date: Fri, 23 Sep 2022 00:24:34 +0200 Subject: [PATCH] Add unit tests for alternative greps in ufw-docker--list --- test/ufw-docker.test.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/ufw-docker.test.sh b/test/ufw-docker.test.sh index 527b5fd..9d5daa7 100755 --- a/test/ufw-docker.test.sh +++ b/test/ufw-docker.test.sh @@ -507,6 +507,29 @@ test-ufw-docker--list-name-80-udp-assert() { } +test-ufw-docker--list-grep-without-network() { + @mocktrue ufw status numbered + @mockfalse grep "# allow foo\\( 80\\/udp\\)\\( [[:graph:]]*\\)\$" + load-ufw-docker-function ufw-docker--list + ufw-docker--list foo 80 udp +} +test-ufw-docker--list-grep-without-network-assert() { + grep "# allow foo\\( 80\\/udp\\)\$" +} + + +test-ufw-docker--list-grep-without-network-and-port() { + @mocktrue ufw status numbered + @mockfalse grep "# allow foo\\( 80\\/udp\\)\\( [[:graph:]]*\\)\$" + @mockfalse grep "# allow foo\\( 80\\/udp\\)\$" + load-ufw-docker-function ufw-docker--list + ufw-docker--list foo 80 udp +} +test-ufw-docker--list-grep-without-network-and-port-assert() { + grep "# allow foo\$" +} + + test-ufw-docker--list-number() { @mocktrue ufw-docker--list foo 53 udp