Merge lp:~bac/juju-gui/fix-goof into lp:juju-gui/experimental

Proposed by Brad Crittenden
Status: Merged
Merged at revision: 501
Proposed branch: lp:~bac/juju-gui/fix-goof
Merge into: lp:juju-gui/experimental
Diff against target: 78 lines (+42/-3)
2 files modified
app/store/endpoints.js (+2/-2)
test/test_endpoints.js (+40/-1)
To merge this branch: bzr merge lp:~bac/juju-gui/fix-goof
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+157197@code.launchpad.net

Description of the change

Fix bug in charm load handler.

https://codereview.appspot.com/8364044/

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :
Download full text (3.4 KiB)

Reviewers: mp+157197_code.launchpad.net,

Message:
Please take a look.

Description:
Fix bug in charm load handler.

https://code.launchpad.net/~bac/juju-gui/fix-goof/+merge/157197

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M app/store/endpoints.js
   M test/test_endpoints.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_endpoints.js
=== modified file 'test/test_endpoints.js'
--- test/test_endpoints.js 2013-04-04 13:28:35 +0000
+++ test/test_endpoints.js 2013-04-04 18:18:21 +0000
@@ -292,7 +292,9 @@
                                 'juju-models',
                                 'juju-tests-utils',
                                 'juju-endpoints-controller',
- 'juju-controllers'],
+ 'juju-controllers',
+ 'juju-charm-store',
+ 'datasource-local'],
      function(Y) {
        juju = Y.namespace('juju');
        utils = Y.namespace('juju-tests.utils');
@@ -415,4 +417,40 @@
      app.db.charms.getById(charm_id).destroy();
    });

+ it('should add the service to the endpoints map when the charm is
loaded',
+ function(done) {
+ var service_name = 'wordpress';
+ var charm_id = 'cs:precise/wordpress-2';
+ app.db.charms.add({id: charm_id});
+ controller.endpointsMap.should.eql({});
+ var charm = app.db.charms.getById(charm_id);
+ var data = [
+ { responseText: Y.JSON.stringify(
+ { summary: 'wowza', subordinate: true, store_revision: 7 })}];
+ var charmStore = new juju.CharmStore({
+ datasource: new Y.DataSource.Local({source: data})});
+
+ app.db.services.add({
+ id: service_name,
+ pending: false,
+ charm: charm_id});
+
+ charm.load(charmStore, function(err, data) {
+ if (err) { assert.fail('should succeed!'); }
+ assert(charm.loaded);
+ charm.get('summary').should.equal('wowza');
+
+ controller.endpointsMap.should.eql({
+ 'wordpress': {
+ provides: [],
+ requires: []
+ }});
+
+ done();
+ });
+
+
+ }
+ );
+
  });

Index: app/store/endpoints.js
=== modified file 'app/store/endpoints.js'
--- app/store/endpoints.js 2013-04-04 14:21:31 +0000
+++ app/store/endpoints.js 2013-04-04 18:18:21 +0000
@@ -111,7 +111,7 @@
          setupCharmOnceLoad: function(charm, svcName) {
            charm.once('load', Y.bind(function(svcName, evt) {
              this.addServiceToEndpointsMap(svcName, evt.currentTarget);
- }, null, svcName));
+ }, this, svcName));
          },

          /**
@@ -133,7 +133,7 @@
              charm = db.charms.add({id: charm_id})
                .load(env,
                  // If views are bound to the charm mode...

Read more...

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

LGTM with comment below. Thanks for the quick fix!

https://codereview.appspot.com/8364044/diff/1/test/test_endpoints.js
File test/test_endpoints.js (right):

https://codereview.appspot.com/8364044/diff/1/test/test_endpoints.js#newcode430
test/test_endpoints.js:430: var charmStore = new juju.CharmStore({
charmStore needs to be destroyed at the end of the test.

https://codereview.appspot.com/8364044/

lp:~bac/juju-gui/fix-goof updated
498. By Brad Crittenden

Destroy object at end of test

Revision history for this message
Richard Harding (rharding) wrote :

LGTM with Jeff's cleanup comment.

https://codereview.appspot.com/8364044/

Revision history for this message
Brad Crittenden (bac) wrote :

*** Submitted:

Fix bug in charm load handler.

R=jeff.pihach, rharding
CC=
https://codereview.appspot.com/8364044

https://codereview.appspot.com/8364044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/store/endpoints.js'
2--- app/store/endpoints.js 2013-04-04 14:21:31 +0000
3+++ app/store/endpoints.js 2013-04-04 18:45:25 +0000
4@@ -111,7 +111,7 @@
5 setupCharmOnceLoad: function(charm, svcName) {
6 charm.once('load', Y.bind(function(svcName, evt) {
7 this.addServiceToEndpointsMap(svcName, evt.currentTarget);
8- }, null, svcName));
9+ }, this, svcName));
10 },
11
12 /**
13@@ -133,7 +133,7 @@
14 charm = db.charms.add({id: charm_id})
15 .load(env,
16 // If views are bound to the charm model, firing "update" is
17- // unnecessary, and potentially even mildly harmful.
18+ // unnecessary, and potentially even mildly harmful.
19 function(err, result) { db.fire('update'); });
20 }
21
22
23=== modified file 'test/test_endpoints.js'
24--- test/test_endpoints.js 2013-04-04 14:45:42 +0000
25+++ test/test_endpoints.js 2013-04-04 18:45:25 +0000
26@@ -292,7 +292,9 @@
27 'juju-models',
28 'juju-tests-utils',
29 'juju-endpoints-controller',
30- 'juju-controllers'],
31+ 'juju-controllers',
32+ 'juju-charm-store',
33+ 'datasource-local'],
34 function(Y) {
35 juju = Y.namespace('juju');
36 utils = Y.namespace('juju-tests.utils');
37@@ -415,4 +417,41 @@
38 app.db.charms.getById(charm_id).destroy();
39 });
40
41+ it('should add the service to the endpoints map when the charm is loaded',
42+ function(done) {
43+ var service_name = 'wordpress';
44+ var charm_id = 'cs:precise/wordpress-2';
45+ app.db.charms.add({id: charm_id});
46+ controller.endpointsMap.should.eql({});
47+ var charm = app.db.charms.getById(charm_id);
48+ var data = [
49+ { responseText: Y.JSON.stringify(
50+ { summary: 'wowza', subordinate: true, store_revision: 7 })}];
51+ var charmStore = new juju.CharmStore({
52+ datasource: new Y.DataSource.Local({source: data})});
53+
54+ app.db.services.add({
55+ id: service_name,
56+ pending: false,
57+ charm: charm_id});
58+
59+ charm.load(charmStore, function(err, data) {
60+ if (err) { assert.fail('should succeed!'); }
61+ assert(charm.loaded);
62+ charm.get('summary').should.equal('wowza');
63+
64+ controller.endpointsMap.should.eql({
65+ 'wordpress': {
66+ provides: [],
67+ requires: []
68+ }});
69+
70+ charmStore.destroy();
71+ done();
72+ });
73+
74+
75+ }
76+ );
77+
78 });

Subscribers

People subscribed via source and target branches