File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import pytest
22
33from .. import base
4- from juju .errors import JujuAPIError
4+ from juju .errors import JujuAPIError , JujuError
55
66
77@base .bootstrapped
@@ -69,3 +69,26 @@ async def test_find_all(event_loop):
6969 for resp in result .result :
7070 assert resp .name != ""
7171 assert resp .type_ in ["charm" , "bundle" ]
72+
73+
74+ @base .bootstrapped
75+ @pytest .mark .asyncio
76+ async def test_subordinate_charm_zero_units (event_loop ):
77+ # normally in pylibjuju deploy num_units defaults to 1, we switch
78+ # that to 0 behind the scenes if we see that the charmhub charm
79+ # we're deploying is a subordinate charm
80+ async with base .CleanModel () as model :
81+
82+ # rsyslog-forwarder-ha is a subordinate charm
83+ app = await model .deploy ('rsyslog-forwarder-ha' )
84+ assert len (app .units ) == 0
85+ await app .destroy ()
86+
87+ # note that it'll error if the user tries to use num_units
88+ with pytest .raises (JujuError ):
89+ await model .deploy ('rsyslog-forwarder-ha' , num_units = 175 )
90+
91+ # (full disclosure: it'll quitely switch to 0 if user enters
92+ # num_units=1)
93+ app2 = await model .deploy ('rsyslog-forwarder-ha' , num_units = 1 )
94+ assert len (app2 .units ) == 0
You can’t perform that action at this time.
0 commit comments