Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JUJU-3887] Avoid removing the track if set to latest in channel normalization #867

Merged
merged 2 commits into from May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion juju/origin.py
Expand Up @@ -97,7 +97,9 @@ def parse(s):
return Channel(track, risk)

def normalize(self):
track = self.track if self.track != "latest" else ""
# TODO (cderici): this is essentially a noop, needs to be revised in both
# 2.9 and 3.x
track = self.track if self.track != "" else ""
risk = self.risk if self.risk != "" else ""
return Channel(track, risk)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_bundle.py
Expand Up @@ -355,7 +355,7 @@ async def test_run_with_charmhub_charm_no_channel(self, event_loop):

context = Mock()
context.resolve.return_value = "ch:charm1"
context.origins = {"ch:charm1": {"stable": Mock()}}
context.origins = {"ch:charm1": {"latest/stable": Mock()}}
context.trusted = False
context.model = model

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_origin.py
Expand Up @@ -30,7 +30,7 @@ def test_parse_numeric(self):

def test_parse_then_normalize(self):
ch = Channel.parse("latest/stable").normalize()
self.assertEqual(ch, Channel(None, "stable"))
self.assertEqual(ch, Channel("latest", "stable"))

def test_str_risk_only(self):
ch = Channel.parse("stable")
Expand All @@ -50,7 +50,7 @@ def test_str_numeric(self):

def test_str_then_normalize(self):
ch = Channel.parse("latest/stable").normalize()
self.assertEqual(str(ch), "stable")
self.assertEqual(str(ch), "latest/stable")


class TestPlatform(unittest.TestCase):
Expand Down