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

Unified Diff: test/test_model.js

Issue 13771047: Use Fakebackend API to perform deployer imports
Patch Set: Use Fakebackend API to perform deployer imports Created 10 years, 6 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/test_fakebackend.js ('k') | test/test_sandbox_python.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/test_model.js
=== modified file 'test/test_model.js'
--- test/test_model.js 2013-09-18 13:39:28 +0000
+++ test/test_model.js 2013-09-19 20:11:53 +0000
@@ -807,181 +807,6 @@
fakeStore.iconpath = function() {return 'fake url';};
});
-
- it('throws an error with more than one import target', function() {
- assert.throws(function() {
- db.importDeployer({a: {}, b: {}});
- }, 'Import target ambigious, aborting.');
- });
-
- it('detects service id collisions', function(done) {
- db.services.add({id: 'mysql', charm: 'cs:precise/mysql-26'});
- var data = {
- a: {services: {mysql: {
- charm: 'cs:precise/mysql-26',
- num_units: 2, options: {debug: false}}}}
- };
-
- assert.throws(function() {
- db.importDeployer(data);
- }, 'mysql is already present in the database.');
-
- var imported = db.importDeployer(data, fakeStore, {rewriteIds: true});
- imported.then(function() {
- assert.equal(db.services.size(), 2);
- done();
- });
- });
-
- it('properly implements inheritence in target definitions', function(done) {
- var data = {
- a: {services: {mysql: {charm: 'cs:precise/mysql-26',
- num_units: 2, options: {debug: false}}}},
- b: {inherits: 'a', services: {mysql: {num_units: 5,
- options: {debug: true}}}},
- c: {inherits: 'b', services: {mysql: {num_units: 3 }}},
- d: {inherits: 'z', services: {mysql: {num_units: 3 }}}
- };
-
-
- // No 'z' available.
- assert.throws(function() {
- db.importDeployer(data, fakeStore, {targetBundle: 'd'});
- }, 'Unable to resolve bundle inheritence.');
-
- db.importDeployer(data, fakeStore, {targetBundle: 'c'})
- .then(function() {
- // Insure that we inherit the debug options from 'b'
- var mysql = db.services.getById('mysql');
- assert.isNotNull(mysql);
- var config = mysql.get('options');
- assert.isTrue(config.debug);
- done();
- });
- });
-
- it('properly implements multiple inheritence', function(done) {
- var data = {
- a: {services: {mysql: {charm: 'cs:precise/mysql-26',
- num_units: 2, options: {debug: false}}}},
- b: {inherits: 'a', services: {mysql: {num_units: 5,
- options: {debug: true}}}},
- c: {inherits: 'a', services: {mysql: {num_units: 3 }}},
- d: {inherits: ['b', 'c'], services: {mysql: {num_units: 3 }}}
- };
-
- db.importDeployer(data, fakeStore, {targetBundle: 'd'})
- .then(function() {
- // Insure that we inherit the debug options from 'b'
- var mysql = db.services.getById('mysql');
- assert.isNotNull(mysql);
- var config = mysql.get('options');
- assert.isTrue(config.debug);
- done();
- }).then(undefined, function(e) {done(e);});
- });
-
-
- it('properly builds relations on import', function(done) {
- var data = {
- a: {
- services: {
- mysql: {
- charm: 'cs:precise/mysql-26',
- num_units: 2, options: {debug: false}},
- wordpress: {
- charm: 'cs:precise/wordpress-15',
- num_units: 1
- }},
- relations: [['mysql', 'wordpress']]
- }};
-
- var importer = db.importDeployer(data, fakeStore, {useGhost: false});
- importer.then(function() {
- var mysql = db.services.getById('mysql');
- var wordpress = db.services.getById('wordpress');
- assert.isNotNull(mysql);
- assert.isNotNull(wordpress);
-
- var rel = db.relations.item(0);
- var ep = rel.get('endpoints');
- // Validate we got the proper interfaces
- assert.equal(ep[0][0], 'wordpress');
- assert.equal(ep[0][1].name, 'db');
- assert.equal(ep[1][0], 'mysql');
- assert.equal(ep[1][1].name, 'db');
- assert.isFalse(rel.get('pending'));
- done();
- }).then(undefined, function(e) {done(e);});
- });
-
- it('properly ghosts services and relations when flagged', function(done) {
- var data = {
- a: {
- services: {
- mysql: {
- charm: 'cs:precise/mysql-26',
- num_units: 2, options: {debug: false}},
- wordpress: {
- charm: 'cs:precise/wordpress-15',
- num_units: 1
- }},
- relations: [['mysql', 'wordpress']]
- }};
-
- var importer = db.importDeployer(data, fakeStore, {useGhost: true});
- importer.then(function() {
- var mysql = db.services.getById('mysql');
- var wordpress = db.services.getById('wordpress');
- assert.isNotNull(mysql);
- assert.isNotNull(wordpress);
- assert.isTrue(mysql.get('pending'));
- assert.isTrue(wordpress.get('pending'));
-
- // Their relation is pending as well.
- var rel = db.relations.item(0);
- assert.isTrue(rel.get('pending'));
- done();
- }).then(undefined, done);
- });
-
- it('should support finding charms through a search', function(done) {
- // Use import to import many charms and then resolve them with a few
- // different keys.
- var defaultSeries = 'precise';
- db.environment.set('defaultSeries', defaultSeries);
- db.importDeployer(jsyaml.safeLoad(utils.loadFixture('data/blog.yaml')),
- fakeStore, {useGhost: true,
- targetBundle: 'wordpress-prod'})
- .then(function() {
- assert.isNotNull(db.charms.find('wordpress', defaultSeries));
- assert.isNotNull(db.charms.find('precise/wordpress', defaultSeries));
- assert.isNotNull(db.charms.find('precise/wordpress'));
- assert.isNotNull(db.charms.find('cs:precise/wordpress'));
- assert.isNotNull(db.charms.find('cs:precise/wordpress-999'));
- // Can't find this w/o a series
- assert.isNull(db.charms.find('wordpress'));
- // Find fails on missing items as well.
- assert.isNull(db.charms.find('foo'));
- assert.isNull(db.charms.find('foo', defaultSeries));
- done();
- }).then(undefined, done);
- });
-
- it('should properly create units when not ghosted');
-
- it('can import from a YAML fixture', function(done) {
- db.environment.set('defaultSeries', 'precise');
- db.importDeployer(jsyaml.safeLoad(utils.loadFixture('data/blog.yaml')),
- fakeStore, {useGhost: true,
- targetBundle: 'wordpress-prod'})
- .then(function() {
- assert.isNotNull(db.services.getById('db'));
- assert.isNotNull(db.services.getById('blog'));
- done();
- });
- });
-
it('can export in deployer format', function() {
db.services.add({id: 'mysql', charm: 'precise/mysql-1'});
db.services.add({
« no previous file with comments | « test/test_fakebackend.js ('k') | test/test_sandbox_python.js » ('j') | no next file with comments »

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