Skip to content

Commit 792f8d5

Browse files
authored
[MISC] Add database field in the provider-side databag (#84)
* Update postgresql_provider.py * fix lint / unit * fix unittest * wip
1 parent 479caa1 commit 792f8d5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/relations/postgresql_provider.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def _on_database_requested(self, event: DatabaseRequestedEvent) -> None:
9292
self.database_provides.set_version(
9393
event.relation.id, self.charm.postgresql.get_postgresql_version()
9494
)
95+
96+
# Set the database name
97+
self.database_provides.set_database(event.relation.id, database)
9598
except (
9699
PostgreSQLCreateDatabaseError,
97100
PostgreSQLCreateUserError,

tests/unit/test_postgresql_provider.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ def request_database(self):
6363
self.harness.update_relation_data(
6464
self.rel_id,
6565
self.app,
66-
{
67-
"data": "",
68-
"username": "",
69-
"password": "",
70-
"version": "",
71-
},
66+
{"data": "", "username": "", "password": "", "version": "", "database": ""},
7267
)
7368

7469
# Simulate the request of a new database plus extra user roles.
@@ -140,6 +135,7 @@ def test_on_database_requested(
140135
"username": user,
141136
"password": "test-password",
142137
"version": POSTGRESQL_VERSION,
138+
"database": f"{DATABASE}",
143139
},
144140
)
145141

0 commit comments

Comments
 (0)