Skip to content

Commit

Permalink
Merge pull request #867 from cderici/channel-normalization-fix-2.9
Browse files Browse the repository at this point in the history
[JUJU-3887] Avoid removing the track if set to latest in channel normalization
  • Loading branch information
juanmanuel-tirado committed May 31, 2023
2 parents 9593122 + 6d7ac14 commit e9eb197
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit e9eb197

Please sign in to comment.