Merge ~mthaddon/charm-k8s-openldap/+git/charm-k8s-openldap:tests into charm-k8s-openldap:master

Proposed by Tom Haddon
Status: Merged
Approved by: Tom Haddon
Approved revision: 20eddc8dae3a6c9187deb5d7d454c08a8d1c5d68
Merged at revision: 6aaccd7c6a52a4f1b06941ef3507235a2722744a
Proposed branch: ~mthaddon/charm-k8s-openldap/+git/charm-k8s-openldap:tests
Merge into: charm-k8s-openldap:master
Diff against target: 29 lines (+6/-1)
2 files modified
src/charm.py (+5/-1)
tests/unit/test_charm.py (+1/-0)
Reviewer Review Type Date Requested Status
David Lawson (community) Approve
Benjamin Allot Approve
Canonical IS Reviewers Pending
Review via email: mp+391527@code.launchpad.net

Commit message

Updates to make tests pass - options in config.yaml are always present at least as an empty string

Description of the change

Updates to make tests pass - options in config.yaml are always present at least as an empty string

To post a comment you must log in.
Revision history for this message
Benjamin Allot (ballot) wrote :

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
David Lawson (deej) wrote :

+1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 6aaccd7c6a52a4f1b06941ef3507235a2722744a

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/charm.py b/src/charm.py
2index bba484a..069d3dd 100755
3--- a/src/charm.py
4+++ b/src/charm.py
5@@ -109,7 +109,11 @@ class OpenLDAPK8sCharm(CharmBase):
6 missing settings; otherwise return an empty list."""
7 config = self.model.config
8
9- missing = {setting for setting in REQUIRED_SETTINGS if setting not in config}
10+ # Options in config.yaml are always present as at least ""
11+ # so config[setting] will not fail with a KeyError if unset via juju.
12+ # We define missing in terms of being required by the charm and explicitly
13+ # set rather than default from config.yaml.
14+ missing = {setting for setting in REQUIRED_SETTINGS if not config[setting]}
15
16 return sorted(missing)
17
18diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py
19index 22746f9..717c937 100644
20--- a/tests/unit/test_charm.py
21+++ b/tests/unit/test_charm.py
22@@ -88,6 +88,7 @@ class TestOpenLDAPK8sCharmHooksDisabled(unittest.TestCase):
23 self.harness.update_config(CONFIG_NO_ADMIN_PASSWORD)
24 self.harness.charm._state.postgres = DB_URI
25 expected = {
26+ 'LDAP_ADMIN_PASSWORD': '',
27 'POSTGRES_NAME': 'openldap',
28 'POSTGRES_USER': 'ldap_user',
29 'POSTGRES_PASSWORD': 'ldap_password',

Subscribers

People subscribed via source and target branches

to all changes: