tests: Fix compatibility with PostgreSQL 14+
It seems postgres-client has changed the format of error messages. Previously we saw messages like: fatal: database "non_existent_database" does not exist These are now prefixed. For example: connection to server at "localhost" (::1), port 5432 failed: fatal: database "non_existent_database" does not exist You can see this in the docs. Compare the "Client Connection Problems" section for Postgres 13 [1] to Postgres 14 [2]. [1] https://www.postgresql.org/docs/13/server-start.html [2] https://www.postgresql.org/docs/14/server-start.html Change-Id: Id2c8eec202d128d142b8a8a8f904fcc14b6f52d7 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-bug: #1989208
This commit is contained in:
parent
995a81d305
commit
437a19703d
@ -462,10 +462,20 @@ class TestNonExistentDatabasePostgreSQL(
|
||||
self.url
|
||||
)
|
||||
self.assertEqual('non_existent_database', matched.database)
|
||||
self.assertInnerException(
|
||||
matched,
|
||||
# NOTE(stephenfin): As above, we cannot use assertInnerException since
|
||||
# the error messages vary depending on the version of PostgreSQL
|
||||
self.assertIsInstance(
|
||||
matched.inner_exception,
|
||||
sqlalchemy.exc.OperationalError,
|
||||
'fatal: database "non_existent_database" does not exist\n',
|
||||
)
|
||||
# On Postgres 13:
|
||||
# fatal: database "non_existent_database" does not exist
|
||||
# On Postgres 14 or later:
|
||||
# connection to server at "localhost" (::1), port 5432 failed: fatal:
|
||||
# database "non_existent_database" does not exist
|
||||
self.assertIn(
|
||||
'fatal: database "non_existent_database" does not exist',
|
||||
str(matched.inner_exception).lower(),
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user