Merge ~jfguedez/juju-lint:neq-fix-and-lint-error into juju-lint:master

Proposed by Jose Guedez
Status: Merged
Approved by: James Troup
Approved revision: aaeb71b9c00a30053a142eecb6bf9a247f0a8e69
Merged at revision: e4a01123bd2ca031412216d6cbee2320f47e94bd
Proposed branch: ~jfguedez/juju-lint:neq-fix-and-lint-error
Merge into: juju-lint:master
Diff against target: 65 lines (+16/-8)
3 files modified
jujulint/lint.py (+1/-3)
jujulint/util.py (+1/-0)
tests/test_jujulint.py (+14/-5)
Reviewer Review Type Date Requested Status
Edin S (community) Approve
Juju Lint maintainers Pending
Review via email: mp+408595@code.launchpad.net

Commit message

Fix issue with 'neq' logic (empty string), and some lint errors

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
Edin S (exsdev) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision e4a01123bd2ca031412216d6cbee2320f47e94bd

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/jujulint/lint.py b/jujulint/lint.py
index 5328723..4648d45 100755
--- a/jujulint/lint.py
+++ b/jujulint/lint.py
@@ -276,9 +276,7 @@ class Linter:
276 operator = ConfigOperator(276 operator = ConfigOperator(
277 name="neq",277 name="neq",
278 repr="!=",278 repr="!=",
279 check=lambda check_value, actual_value: not helper_operator_eq_check(279 check=lambda check_value, actual_value: check_value != actual_value,
280 check_value, actual_value
281 ),
282 error_template="Application {} has incorrect setting for '{}': Should not be {}",280 error_template="Application {} has incorrect setting for '{}': Should not be {}",
283 )281 )
284282
diff --git a/jujulint/util.py b/jujulint/util.py
index bdd7008..b8c1359 100644
--- a/jujulint/util.py
+++ b/jujulint/util.py
@@ -47,6 +47,7 @@ def is_container(machine):
4747
4848
49def extract_charm_name(charm):49def extract_charm_name(charm):
50 """Extract the charm name using regex."""
50 match = re.match(51 match = re.match(
51 r"^(?:\w+:)?(?:~[\w\.-]+/)?(?:\w+/)?([a-zA-Z0-9-]+?)(?:-\d+)?$", charm52 r"^(?:\w+:)?(?:~[\w\.-]+/)?(?:\w+/)?([a-zA-Z0-9-]+?)(?:-\d+)?$", charm
52 )53 )
diff --git a/tests/test_jujulint.py b/tests/test_jujulint.py
index cd41c58..96499d2 100644
--- a/tests/test_jujulint.py
+++ b/tests/test_jujulint.py
@@ -301,10 +301,19 @@ class TestLinter:
301 assert errors[0]["expected_value"] is False301 assert errors[0]["expected_value"] is False
302 assert errors[0]["actual_value"] is True302 assert errors[0]["actual_value"] is True
303303
304 def test_config_neq(self, linter, juju_status):304 def test_config_neq_valid(self, linter, juju_status):
305 """Test the config condition 'neq'."""305 """Test the config condition 'neq'."""
306 linter.lint_rules["config"] = {"ubuntu": {"fake-opt": {"neq": False}}}306 linter.lint_rules["config"] = {"ubuntu": {"fake-opt": {"neq": "foo"}}}
307 juju_status["applications"]["ubuntu"]["options"] = {"fake-opt": False}307 juju_status["applications"]["ubuntu"]["options"] = {"fake-opt": "bar"}
308 linter.do_lint(juju_status)
309
310 errors = linter.output_collector["errors"]
311 assert len(errors) == 0
312
313 def test_config_neq_invalid(self, linter, juju_status):
314 """Test the config condition 'neq', valid."""
315 linter.lint_rules["config"] = {"ubuntu": {"fake-opt": {"neq": ""}}}
316 juju_status["applications"]["ubuntu"]["options"] = {"fake-opt": ""}
308 linter.do_lint(juju_status)317 linter.do_lint(juju_status)
309318
310 errors = linter.output_collector["errors"]319 errors = linter.output_collector["errors"]
@@ -312,8 +321,8 @@ class TestLinter:
312 assert errors[0]["id"] == "config-neq-check"321 assert errors[0]["id"] == "config-neq-check"
313 assert errors[0]["application"] == "ubuntu"322 assert errors[0]["application"] == "ubuntu"
314 assert errors[0]["rule"] == "fake-opt"323 assert errors[0]["rule"] == "fake-opt"
315 assert errors[0]["expected_value"] is False324 assert errors[0]["expected_value"] == ""
316 assert errors[0]["actual_value"] is False325 assert errors[0]["actual_value"] == ""
317326
318 def test_config_gte(self, linter, juju_status):327 def test_config_gte(self, linter, juju_status):
319 """Test the config condition 'gte'."""328 """Test the config condition 'gte'."""

Subscribers

People subscribed via source and target branches