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

Side by Side Diff: test/test_model.js

Issue 14695043: Redo Service Placement
Patch Set: Created 11 years, 6 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
11 ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, 11 ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero 12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License along 15 You should have received a copy of the GNU Affero General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>. 16 with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 'use strict'; 19 'use strict';
20 20
21 describe('test_models.js', function() { 21 describe('test_model.js', function() {
22 describe('Charm initialization', function() { 22 describe('Charm initialization', function() {
23 var models; 23 var models;
24 24
25 before(function(done) { 25 before(function(done) {
26 YUI(GlobalConfig).use('juju-models', 'juju-charm-models', function(Y) { 26 YUI(GlobalConfig).use('juju-models', 'juju-charm-models', function(Y) {
27 models = Y.namespace('juju.models'); 27 models = Y.namespace('juju.models');
28 done(); 28 done();
29 }); 29 });
30 }); 30 });
31 31
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 }); 790 });
791 }); 791 });
792 792
793 beforeEach(function() { 793 beforeEach(function() {
794 db = new models.Database(); 794 db = new models.Database();
795 fakeStore = utils.makeFakeStore(db.charms); 795 fakeStore = utils.makeFakeStore(db.charms);
796 fakeStore.iconpath = function() {return 'fake url';}; 796 fakeStore.iconpath = function() {return 'fake url';};
797 }); 797 });
798 798
799 it('can export in deployer format', function() { 799 it('can export in deployer format', function() {
800 // Mock a topology that can return positions.
801 var topology = {
802 service_boxes: {
803 wordpress: {
804 x: 100,
805 y: 200
806 },
807 mysql: {x: 0, y: 0}
808 }
809 };
810
800 db.services.add({id: 'mysql', charm: 'precise/mysql-1'}); 811 db.services.add({id: 'mysql', charm: 'precise/mysql-1'});
801 db.services.add({ 812 db.services.add({
802 id: 'wordpress', 813 id: 'wordpress',
803 charm: 'precise/wordpress-1', 814 charm: 'precise/wordpress-1',
804 config: {debug: 'no', username: 'admin'}, 815 config: {debug: 'no', username: 'admin'},
805 constraints: 'cpu-power=2,cpu-cores=4', 816 constraints: 'cpu-power=2,cpu-cores=4',
806 annotations: {'gui-x': 100, 'gui-y': 200, 'ignored': true}
807 }); 817 });
808 db.relations.add({ 818 db.relations.add({
809 id: 'relation-0', 819 id: 'relation-0',
810 endpoints: [ 820 endpoints: [
811 ['mysql', {name: 'db', role: 'server'}], 821 ['mysql', {name: 'db', role: 'server'}],
812 ['wordpress', {name: 'app', role: 'client'}]], 822 ['wordpress', {name: 'app', role: 'client'}]],
813 'interface': 'db' 823 'interface': 'db'
814 }); 824 });
815 825
816 db.environment.set('defaultSeries', 'precise'); 826 db.environment.set('defaultSeries', 'precise');
817 827
818 // Add the charms so we can resolve them in the export. 828 // Add the charms so we can resolve them in the export.
819 db.charms.add([{id: 'precise/mysql-1'}, 829 db.charms.add([{id: 'precise/mysql-1'},
820 {id: 'precise/wordpress-1', 830 {id: 'precise/wordpress-1',
821 options: { 831 options: {
822 debug: { 832 debug: {
823 'default': 'no' 833 'default': 'no'
824 }, 834 },
825 username: { 835 username: {
826 'default': 'root' 836 'default': 'root'
827 } 837 }
828 } 838 }
829 } 839 }
830 ]); 840 ]);
831 var result = db.exportDeployer().envExport; 841 var result = db.exportDeployer(topology).envExport;
gary.poster 2013/10/15 15:34:16 Back to first comment: I'd hope this is no longer
benjamin.saller 2013/10/15 19:40:11 It took some reworking to really get there, but it
832 var relation = result.relations[0]; 842 var relation = result.relations[0];
833 843
834 assert.equal(result.series, 'precise'); 844 assert.equal(result.series, 'precise');
835 assert.equal(result.services.mysql.charm, 'precise/mysql-1'); 845 assert.equal(result.services.mysql.charm, 'precise/mysql-1');
836 assert.equal(result.services.wordpress.charm, 'precise/wordpress-1'); 846 assert.equal(result.services.wordpress.charm, 'precise/wordpress-1');
837 847
838 // A default config value is skipped 848 // A default config value is skipped
839 assert.equal(result.services.wordpress.options.debug, undefined); 849 assert.equal(result.services.wordpress.options.debug, undefined);
840 // A value changed from the default is exported 850 // A value changed from the default is exported
841 assert.equal(result.services.wordpress.options.username, 'admin'); 851 assert.equal(result.services.wordpress.options.username, 'admin');
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 assert.isFalse(mysql.hasErrors(), mysql.get('id')); 920 assert.isFalse(mysql.hasErrors(), mysql.get('id'));
911 }); 921 });
912 922
913 it('can be filtered so that it returns only visible models', function() { 923 it('can be filtered so that it returns only visible models', function() {
914 var filtered = list.visible(); 924 var filtered = list.visible();
915 assert.strictEqual(2, filtered.size()); 925 assert.strictEqual(2, filtered.size());
916 assert.deepEqual([django, wordpress], filtered.toArray()); 926 assert.deepEqual([django, wordpress], filtered.toArray());
917 }); 927 });
918 }); 928 });
919 }); 929 });
OLDNEW

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