Skip to content

Commit e9eb197

Browse files
Merge pull request #867 from cderici/channel-normalization-fix-2.9
[JUJU-3887] Avoid removing the track if set to latest in channel normalization
2 parents 9593122 + 6d7ac14 commit e9eb197

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

juju/origin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ def parse(s):
9797
return Channel(track, risk)
9898

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

tests/unit/test_bundle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ async def test_run_with_charmhub_charm_no_channel(self, event_loop):
355355

356356
context = Mock()
357357
context.resolve.return_value = "ch:charm1"
358-
context.origins = {"ch:charm1": {"stable": Mock()}}
358+
context.origins = {"ch:charm1": {"latest/stable": Mock()}}
359359
context.trusted = False
360360
context.model = model
361361

tests/unit/test_origin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_parse_numeric(self):
3030

3131
def test_parse_then_normalize(self):
3232
ch = Channel.parse("latest/stable").normalize()
33-
self.assertEqual(ch, Channel(None, "stable"))
33+
self.assertEqual(ch, Channel("latest", "stable"))
3434

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

5151
def test_str_then_normalize(self):
5252
ch = Channel.parse("latest/stable").normalize()
53-
self.assertEqual(str(ch), "stable")
53+
self.assertEqual(str(ch), "latest/stable")
5454

5555

5656
class TestPlatform(unittest.TestCase):

0 commit comments

Comments
 (0)