Merge ~mthaddon/charm-k8s-unifi-poller/+git/charm-k8s-unifi-poller:test-bad-url-scheme into charm-k8s-unifi-poller:master

Proposed by Tom Haddon
Status: Merged
Approved by: Tom Haddon
Approved revision: 68e1389a665c4768494fbf9daf82386fe4098959
Merged at revision: df3e5b21613a6da63677cce9e0a7bdc49034b329
Proposed branch: ~mthaddon/charm-k8s-unifi-poller/+git/charm-k8s-unifi-poller:test-bad-url-scheme
Merge into: charm-k8s-unifi-poller:master
Diff against target: 28 lines (+10/-0)
1 file modified
tests/unit/test_charm.py (+10/-0)
Reviewer Review Type Date Requested Status
Gareth Woolridge Approve
Canonical IS Reviewers Pending
Review via email: mp+390540@code.launchpad.net

Commit message

Add test of invalid netloc, as well as valid url to confirm we're exercising both code paths

Description of the change

Add test of invalid netloc, as well as valid url to confirm we're exercising both code paths.

Without this change we were seeing "82->76" in the missing code coverage, which means the code path where it's going from line 82 to line 76 wasn't covered. This now covers that.

To post a comment you must log in.
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
Gareth Woolridge (moon127) wrote :

LGTM!

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

Change successfully merged at revision df3e5b21613a6da63677cce9e0a7bdc49034b329

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py
2index d3e787a..42b6066 100644
3--- a/tests/unit/test_charm.py
4+++ b/tests/unit/test_charm.py
5@@ -85,6 +85,13 @@ CONFIG_INVALID_EXTRA_CONFIG_NO_IMAGE = {
6 up_unifi_controller_1_pass=unifipoller, influx_interval=60s]",
7 }
8
9+# The first entry is valid, the second isn't, to ensure we exercise the
10+# code path where we're not appending to errors for an invalid url.scheme
11+# or missing url.netloc, as well as when we are appending errors.
12+CONFIG_INVALID_EXTRA_CONFIG_NO_NETLOC = {
13+ 'extra_configs': "[up_unifi_controller_1_url=http://valid-url, up_unifi_controller_2_url=https:no-netloc]",
14+}
15+
16
17 class TestCharm(unittest.TestCase):
18 def setUp(self):
19@@ -111,6 +118,9 @@ class TestCharm(unittest.TestCase):
20 self.harness.update_config(CONFIG_INVALID_EXTRA_CONFIG)
21 expected = 'invalid extra_config setting(s): influx_interval, up_unifi_controller_1_url'
22 self.assertEqual(self.harness.charm._check_for_config_problems(), expected)
23+ self.harness.update_config(CONFIG_INVALID_EXTRA_CONFIG_NO_NETLOC)
24+ expected = 'invalid extra_config setting(s): up_unifi_controller_2_url'
25+ self.assertEqual(self.harness.charm._check_for_config_problems(), expected)
26
27 def test_check_for_missing_image_invalid_extra_config(self):
28 """Check for correctly reports invalid extra_configs options."""

Subscribers

People subscribed via source and target branches