tzssangglass commented on a change in pull request #5675:
URL: https://github.com/apache/apisix/pull/5675#discussion_r762587621



##########
File path: t/cli/test_main.sh
##########
@@ -310,6 +310,45 @@ fi
 
 echo "pass: support environment variables in local_conf"
 
+# should use default value when environment not set
+echo '
+tests:
+    key: ${{TEST_ENV::1.1.1.1}}
+' > conf/config.yaml
+
+make init
+
+if ! grep "env TEST_ENV=1.1.1.1;" conf/nginx.conf > /dev/null; then
+    echo "failed: should use default value when environment not set"
+    exit 1
+fi
+
+echo '
+tests:
+    key: 
${{TEST_ENV::very-long-domain-with-many-symbols.absolutely-non-exists-123ss.com:1234/path?param1=value1}}
+' > conf/config.yaml
+
+make init
+
+if ! grep "env 
TEST_ENV=very-long-domain-with-many-symbols.absolutely-non-exists-123ss.com:1234/path?param1=value1;"
 conf/nginx.conf > /dev/null; then
+    echo "failed: should use default value when environment not set"
+    exit 1
+fi
+
+echo '
+tests:
+    key: ${{TEST_ENV::192.168.1.1}}
+' > conf/config.yaml
+
+TEST_ENV=127.0.0.1 make init
+
+if ! grep "env TEST_ENV=127.0.0.1;" conf/nginx.conf > /dev/null; then
+    echo "failed: should use default value when environment not set"
+    exit 1
+fi
+
+echo "pass: should use default value when environment not set"

Review comment:
       we can use `support default value when environment not set` here. 
Earlier I suggested taht change `echo "failed: support default value when 
environment not set"` to `echo "failed: should use default value when 
environment not set"` above is to output exactly that failed test case when it 
fails. If the error output is the same for all three tests above, then when an 
error occurs we need to take the time to see which one is actually wrong.
   
   I think you can tweak the error output of the test case a little.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to