phanikumv commented on code in PR #68913:
URL: https://github.com/apache/airflow/pull/68913#discussion_r3466203578


##########
airflow-core/tests/unit/cli/commands/test_db_command.py:
##########
@@ -534,6 +534,15 @@ def test_cli_shell_invalid_ppg3(self):
         with pytest.raises(AirflowException, match=r"Unknown driver: 
invalid\+psycopg"):
             db_command.shell(self.parser.parse_args(["db", "shell"]))
 
+    @mock.patch(
+        "airflow.cli.commands.db_command.settings.engine.url",
+        make_url("postgresql+psycopg2://postgres:airflow@postgres/"),
+    )
+    def test_db_shell_missing_database_name(self):
+        """Assert that an explicit ValueError is raised when the database name 
is missing."""
+        with pytest.raises(ValueError, match="The metadata database name is 
missing"):
+            db_command.shell(self.parser.parse_args(["db", "shell"]))
+

Review Comment:
   The URL the bug was actually reported with is 
`postgresql://postgres:postgres@postgres:5432` — no trailing slash, which 
parses to `url.database = None`. That `None` is what blew up the original code
     (`env["PGDATABASE"] = None`).
   
   Your test uses the trailing-slash form 
`postgresql+psycopg2://postgres:airflow@postgres/`, which gives you `''` 
instead of `None`. The test isn't feeding in the exact input from the report. 
   Easiest fix is to just cover both.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to