Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(149)

Side by Side Diff: test/test_endpoints.js

Issue 13286043: Switch the default environment to Go.
Patch Set: Created 11 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 This file is part of the Juju GUI, which lets users view and manage Juju 2 This file is part of the Juju GUI, which lets users view and manage Juju
3 environments within a graphical interface (https://launchpad.net/juju-gui). 3 environments within a graphical interface (https://launchpad.net/juju-gui).
4 Copyright (C) 2012-2013 Canonical Ltd. 4 Copyright (C) 2012-2013 Canonical Ltd.
5 5
6 This program is free software: you can redistribute it and/or modify it under 6 This program is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Affero General Public License version 3, as published by 7 the terms of the GNU Affero General Public License version 3, as published by
8 the Free Software Foundation. 8 the Free Software Foundation.
9 9
10 This program is distributed in the hope that it will be useful, but WITHOUT 10 This program is distributed in the hope that it will be useful, but WITHOUT
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 controller = app.endpointsController; 530 controller = app.endpointsController;
531 destroyMe.push(controller); 531 destroyMe.push(controller);
532 }); 532 });
533 533
534 afterEach(function() { 534 afterEach(function() {
535 Y.each(destroyMe, function(thing) { 535 Y.each(destroyMe, function(thing) {
536 thing.destroy(); 536 thing.destroy();
537 }); 537 });
538 }); 538 });
539 539
540 it('should not call get_service when a pending service is added', 540 // Ensure the last message in the connection is a ServiceGet request.
541 var assertServiceGetCalled = function() {
542 assert.equal(1, conn.messages.length);
543 assert.equal('ServiceGet', conn.last_message().Request);
jeff.pihach 2013/08/27 16:55:01 The syntax here is reversed.
544 };
545
546 it('should not call ServiceGet when a pending service is added',
541 function() { 547 function() {
542 var charm_id = 'cs:precise/wordpress-2'; 548 var charm_id = 'cs:precise/wordpress-2';
543 app.db.services.add({ 549 app.db.services.add({
544 id: 'wordpress', 550 id: 'wordpress',
545 pending: true, 551 pending: true,
546 charm: charm_id}); 552 charm: charm_id});
547 assert.equal(0, conn.messages.length); 553 assert.equal(0, conn.messages.length);
548 }); 554 });
549 555
550 it('should call get_service when non-pending services are added', 556 it('should call ServiceGet when non-pending services are added',
551 function() { 557 function() {
552 var service_name = 'wordpress'; 558 var service_name = 'wordpress';
553 var charm_id = 'cs:precise/wordpress-2'; 559 var charm_id = 'cs:precise/wordpress-2';
554 var charm = app.db.charms.add({id: charm_id}); 560 var charm = app.db.charms.add({id: charm_id});
555 destroyMe.push(charm); 561 destroyMe.push(charm);
556 charm.loaded = true; 562 charm.loaded = true;
557 app.db.services.add({ 563 app.db.services.add({
558 id: service_name, 564 id: service_name,
559 pending: true, 565 pending: true,
560 charm: charm_id}); 566 charm: charm_id});
561 var svc = app.db.services.getById(service_name); 567 var svc = app.db.services.getById(service_name);
562 svc.set('pending', false); 568 svc.set('pending', false);
563 assert.equal(1, conn.messages.length); 569 assertServiceGetCalled();
564 assert.equal('get_service', conn.last_message().op);
565 }); 570 });
566 571
567 it('should call get_service when a service\'s charm changes', function() { 572 it('should call ServiceGet when a service\'s charm changes', function() {
568 var service_name = 'wordpress'; 573 var service_name = 'wordpress';
569 var charm_id = 'cs:precise/wordpress-2'; 574 var charm_id = 'cs:precise/wordpress-2';
570 var charm = app.db.charms.add({id: charm_id}); 575 var charm = app.db.charms.add({id: charm_id});
571 destroyMe.push(charm); 576 destroyMe.push(charm);
572 charm.loaded = true; 577 charm.loaded = true;
573 app.db.services.add({ 578 app.db.services.add({
574 id: service_name, 579 id: service_name,
575 pending: false, 580 pending: false,
576 charm: charm_id}); 581 charm: charm_id});
577 assert.equal(1, conn.messages.length); 582 assertServiceGetCalled();
578 assert.equal('get_service', conn.last_message().op);
579 var svc = app.db.services.getById(service_name); 583 var svc = app.db.services.getById(service_name);
580 charm_id = 'cs:precise/wordpress-3'; 584 charm_id = 'cs:precise/wordpress-3';
581 var charm2 = app.db.charms.add({id: charm_id, loaded: true}); 585 var charm2 = app.db.charms.add({id: charm_id, loaded: true});
582 destroyMe.push(charm2); 586 destroyMe.push(charm2);
583 svc.set('charm', charm_id); 587 svc.set('charm', charm_id);
584 assert.equal(1, conn.messages.length); 588 assertServiceGetCalled();
585 assert.equal('get_service', conn.last_message().op);
586 }); 589 });
587 590
588 }); 591 });
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b