Merge lp:~hatch/juju-gui/default-bundle-unit into lp:juju-gui/experimental

Proposed by Jeff Pihach
Status: Merged
Merged at revision: 1168
Proposed branch: lp:~hatch/juju-gui/default-bundle-unit
Merge into: lp:juju-gui/experimental
Diff against target: 45 lines (+15/-2)
2 files modified
app/store/env/fakebackend.js (+8/-2)
test/test_fakebackend.js (+7/-0)
To merge this branch: bzr merge lp:~hatch/juju-gui/default-bundle-unit
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+193341@code.launchpad.net

Description of the change

Handle unit numbers properly with subordinates

https://codereview.appspot.com/20040043/

To post a comment you must log in.
Revision history for this message
Jeff Pihach (hatch) wrote :

Reviewers: mp+193341_code.launchpad.net,

Message:
Please take a look.

Description:
Handle unit numbers properly with subordinates

https://code.launchpad.net/~hatch/juju-gui/default-bundle-unit/+merge/193341

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/20040043/

Affected files (+17, -2 lines):
   A [revision details]
   M app/store/env/fakebackend.js
   M test/test_fakebackend.js

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: test/test_fakebackend.js
=== modified file 'test/test_fakebackend.js'
--- test/test_fakebackend.js 2013-10-23 05:23:16 +0000
+++ test/test_fakebackend.js 2013-10-30 21:58:08 +0000
@@ -1102,6 +1102,13 @@
        assert.equal(result.machines[0].agent_state, 'running');
      });

+ it('deploys subordinates without adding units', function() {
+ fakebackend.deploy('cs:precise/puppet-5', callback);
+ assert.equal(deployResult.service.get('name'), 'puppet');
+ assert.equal(deployResult.units.length, 0);
+ assert.equal(deployResult.service.get('units').size(), 0);
+ });
+
      it('adds multiple units', function() {
        fakebackend.deploy('cs:precise/wordpress-15', callback);
        assert.isUndefined(deployResult.error);

Index: app/store/env/fakebackend.js
=== modified file 'app/store/env/fakebackend.js'
--- app/store/env/fakebackend.js 2013-10-23 05:17:56 +0000
+++ app/store/env/fakebackend.js 2013-10-30 21:58:08 +0000
@@ -444,7 +444,13 @@
          })()
        });
        this.changes.services[service.get('id')] = [service, true];
- var response = this.addUnit(options.name, options.unitCount);
+
+ var unitCount = options.unitCount;
+ if (!Y.Lang.isValue(unitCount) && !charm.get('is_subordinate')) {
+ // This is the current behavior in both implementations.
+ unitCount = 1;
+ }
+ var response = this.addUnit(options.name, unitCount);
        response.service = service;
        callback(response);
      },
@@ -1495,7 +1501,7 @@
          // Map the argument name from the deployer format
          // name for unit count.
          if (!serviceData.unitCount) {
- serviceData.unitCount = serviceData.num_units || 1;
+ serviceData.unitCount = serviceData.num_units;
          }
          if (serviceData.options) {
            serviceData.config = serviceData.options;

Revision history for this message
Gary Poster (gary) wrote :
Revision history for this message
Jeff Pihach (hatch) wrote :

*** Submitted:

Handle unit numbers properly with subordinates

R=gary.poster
CC=
https://codereview.appspot.com/20040043

https://codereview.appspot.com/20040043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/store/env/fakebackend.js'
2--- app/store/env/fakebackend.js 2013-10-23 05:17:56 +0000
3+++ app/store/env/fakebackend.js 2013-10-30 22:04:36 +0000
4@@ -444,7 +444,13 @@
5 })()
6 });
7 this.changes.services[service.get('id')] = [service, true];
8- var response = this.addUnit(options.name, options.unitCount);
9+
10+ var unitCount = options.unitCount;
11+ if (!Y.Lang.isValue(unitCount) && !charm.get('is_subordinate')) {
12+ // This is the current behavior in both implementations.
13+ unitCount = 1;
14+ }
15+ var response = this.addUnit(options.name, unitCount);
16 response.service = service;
17 callback(response);
18 },
19@@ -1495,7 +1501,7 @@
20 // Map the argument name from the deployer format
21 // name for unit count.
22 if (!serviceData.unitCount) {
23- serviceData.unitCount = serviceData.num_units || 1;
24+ serviceData.unitCount = serviceData.num_units;
25 }
26 if (serviceData.options) {
27 serviceData.config = serviceData.options;
28
29=== modified file 'test/test_fakebackend.js'
30--- test/test_fakebackend.js 2013-10-23 05:23:16 +0000
31+++ test/test_fakebackend.js 2013-10-30 22:04:36 +0000
32@@ -1102,6 +1102,13 @@
33 assert.equal(result.machines[0].agent_state, 'running');
34 });
35
36+ it('deploys subordinates without adding units', function() {
37+ fakebackend.deploy('cs:precise/puppet-5', callback);
38+ assert.equal(deployResult.service.get('name'), 'puppet');
39+ assert.equal(deployResult.units.length, 0);
40+ assert.equal(deployResult.service.get('units').size(), 0);
41+ });
42+
43 it('adds multiple units', function() {
44 fakebackend.deploy('cs:precise/wordpress-15', callback);
45 assert.isUndefined(deployResult.error);

Subscribers

People subscribed via source and target branches