Skip to content

Commit 48377ec

Browse files
committed
test: add env var used as config key resolution test
1 parent 534473d commit 48377ec

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

t/cli/test_http_config.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,31 @@ echo "passed: define custom shdict"
3939

4040
git checkout conf/config.yaml
4141

42+
# resolve environment variable used as a config key: the resolved key must be
43+
# rendered and the stale unresolved key must be removed from the config table
44+
echo '
45+
nginx_config:
46+
http:
47+
custom_lua_shared_dict:
48+
"${{DICT_NAME}}": 1m
49+
' > conf/config.yaml
50+
51+
DICT_NAME=env_dict make init
52+
53+
if ! grep "lua_shared_dict env_dict 1m;" conf/nginx.conf > /dev/null; then
54+
echo "failed: resolve env var used as config key"
55+
exit 1
56+
fi
57+
58+
if grep -F '${{DICT_NAME}}' conf/nginx.conf > /dev/null; then
59+
echo "failed: stale unresolved env var key should be removed"
60+
exit 1
61+
fi
62+
63+
echo "passed: resolve env var used as config key"
64+
65+
git checkout conf/config.yaml
66+
4267
echo "
4368
plugins:
4469
- ip-restriction

0 commit comments

Comments
 (0)