From 52fa5dc1e1d27d072b7d06854cf7dbe8a5290dcc Mon Sep 17 00:00:00 2001 From: Chai Feng Date: Sun, 20 Oct 2019 18:48:43 +0200 Subject: [PATCH] Add a test case for ufw-docker--get-env-list --- test/ufw-docker-service.test.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/ufw-docker-service.test.sh b/test/ufw-docker-service.test.sh index a11ffc9..4495fb5 100755 --- a/test/ufw-docker-service.test.sh +++ b/test/ufw-docker-service.test.sh @@ -236,3 +236,26 @@ test-ufw-docker--service-allow-a-service-update-a-env-assert() { --image "chaifeng/ufw-docker-agent:181005" \ ufw-docker-agent } + + +test-ufw-docker--get-env-list() { + @mock docker service inspect ufw-docker-agent \ + --format '{{range $k,$v := .Spec.TaskTemplate.ContainerSpec.Env}}{{ $v }}{{"\n"}}{{end}}' \ + === @stdout \ + "ufw_docker_agent_image=192.168.56.130:5000/chaifeng/ufw-docker-agent:test" \ + "DEBUG=true" \ + "ufw_public_zv6esvmwnmmgnlauqn7m77jo4=webapp/9090/tcp" \ + "OTHER_ENV=blabla" + + @mock sed -e '/^ufw_public_/!d' \ + -e 's/^ufw_public_//' \ + -e 's/=/ /' === @real sed -e '/^ufw_public_/!d' \ + -e 's/^ufw_public_//' \ + -e 's/=/ /' + + load-ufw-docker-function ufw-docker--get-env-list + ufw-docker--get-env-list +} +test-ufw-docker--get-env-list-assert() { + @stdout "zv6esvmwnmmgnlauqn7m77jo4 webapp/9090/tcp" +}