Add tests for ufw-docker--instance-name

This commit is contained in:
Chai Feng 2019-10-19 12:20:05 +02:00
parent 8444f87760
commit 1c6dd31de7

View File

@ -17,6 +17,7 @@ source "$working_dir"/bach/bach.sh
@ignore err
DEFAULT_PROTO=tcp
GREP_REGEXP_INSTANCE_NAME="[-_.[:alnum:]]\\+"
}
function ufw-docker() {
@ -350,3 +351,32 @@ test-ufw-docker--add-rule-modify-an-existing-rule-without-port-assert() {
ufw route allow proto tcp from any to 172.18.0.4 comment "allow webapp"
}
test-ufw-docker--instance-name-found-a-name() {
@mock docker inspect --format="{{.Name}}" foo
@mock sed -e 's,^/,,'
@mockfalse grep "^$GREP_REGEXP_INSTANCE_NAME\$"
@mock echo -n foo
load-ufw-docker-function ufw-docker--instance-name
ufw-docker--instance-name foo
}
test-ufw-docker--instance-name-found-a-name-assert() {
docker inspect --format="{{.Name}}" foo
echo -n foo
}
test-ufw-docker--instance-name-found-an-id() {
@mock docker inspect --format="{{.Name}}" fooid
@mock sed -e 's,^/,,'
@mockfalse grep "^$GREP_REGEXP_INSTANCE_NAME\$"
load-ufw-docker-function ufw-docker--instance-name
ufw-docker--instance-name fooid
}
test-ufw-docker--instance-name-found-an-id-assert() {
docker inspect --format="{{.Name}}" fooid
}