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

Delta Between Two Patch Sets: test/test_fakebackend.js

Issue 8578043: Implemented add-relation for the fakebackend
Left Patch Set: Implemented add-relation for the fakebackend Created 11 years, 12 months ago
Right Patch Set: Implemented add-relation for the fakebackend Created 11 years, 12 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/data/puppet-charmdata.json ('k') | test/test_sandbox.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 'use strict'; 1 'use strict';
2 2
3 (function() { 3 (function() {
4
5 // Helpers
6 // Verify that an expected Error was found.
7 var ERROR = function(errString, done) {
8 return function(result) {
9 assert.equal(errString, result.error);
10 done();
11 };
12 };
13
4 14
5 describe('FakeBackend.login', function() { 15 describe('FakeBackend.login', function() {
6 var requires = ['node', 'juju-env-fakebackend']; 16 var requires = ['node', 'juju-env-fakebackend'];
7 var Y, environmentsModule, fakebackend; 17 var Y, environmentsModule, fakebackend;
8 18
9 before(function(done) { 19 before(function(done) {
10 Y = YUI(GlobalConfig).use(requires, function(Y) { 20 Y = YUI(GlobalConfig).use(requires, function(Y) {
11 environmentsModule = Y.namespace('juju.environments'); 21 environmentsModule = Y.namespace('juju.environments');
12 done(); 22 done();
13 }); 23 });
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 assert.isObject(service); 89 assert.isObject(service);
80 assert.strictEqual(service, result.service); 90 assert.strictEqual(service, result.service);
81 var attrs = service.getAttrs(); 91 var attrs = service.getAttrs();
82 // clientId varies. 92 // clientId varies.
83 assert.isTrue(Y.Lang.isString(attrs.clientId)); 93 assert.isTrue(Y.Lang.isString(attrs.clientId));
84 delete attrs.clientId; 94 delete attrs.clientId;
85 assert.deepEqual(attrs, { 95 assert.deepEqual(attrs, {
86 aggregated_status: undefined, 96 aggregated_status: undefined,
87 charm: 'cs:precise/wordpress-10', 97 charm: 'cs:precise/wordpress-10',
88 config: undefined, 98 config: undefined,
89 constraints: undefined, 99 constraints: {},
90 destroyed: false, 100 destroyed: false,
91 displayName: 'wordpress', 101 displayName: 'wordpress',
92 exposed: false, 102 exposed: false,
93 id: 'wordpress', 103 id: 'wordpress',
94 initialized: true, 104 initialized: true,
95 name: 'wordpress', 105 name: 'wordpress',
96 pending: false, 106 pending: false,
97 subordinate: false, 107 subordinate: false,
98 unit_count: undefined 108 unit_count: undefined
99 }); 109 });
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 callback, 217 callback,
208 {configYAML: 'auto_id: %n'}); 218 {configYAML: 'auto_id: %n'});
209 assert.equal( 219 assert.equal(
210 result.error, 220 result.error,
211 'Error parsing YAML.\n' + 221 'Error parsing YAML.\n' +
212 'JS-YAML: end of the stream or a document separator is expected ' + 222 'JS-YAML: end of the stream or a document separator is expected ' +
213 'at line 1, column 10:\n' + 223 'at line 1, column 10:\n' +
214 ' auto_id: %n\n' + 224 ' auto_id: %n\n' +
215 ' ^'); 225 ' ^');
216 }); 226 });
217 227 });
228
229 describe('FakeBackend.uniformOperations', function() {
230 var requires = [
231 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models'];
232 var Y, fakebackend, utils, setCharm;
233
234 before(function(done) {
235 Y = YUI(GlobalConfig).use(requires, function(Y) {
236 utils = Y.namespace('juju-tests.utils');
237 done();
238 });
239 });
240
241 beforeEach(function() {
242 var setupData = utils.makeFakeBackendWithCharmStore();
243 fakebackend = setupData.fakebackend;
244 setCharm = setupData.setCharm;
245 });
246
247 afterEach(function() {
248 fakebackend.destroy();
249 });
250
251 describe('FakeBackend.resolved', function(done) {
252
253 it('rejects unauthenticated calls', function() {
254 fakebackend.logout();
255 var result = fakebackend.resolved('wordpress/0');
256 assert.equal(result.error, 'Please log in.');
257 });
258
259 it('reports invalid untis', function() {
260 var result = fakebackend.resolved('wordpress/0');
261 assert.equal(result.error, 'Unit "wordpress/0" does not exist.');
262 });
263
264 it('reports invalid relations', function(done) {
265 fakebackend.deploy('cs:wordpress', function() {
266 var result = fakebackend.resolved('wordpress/0', 'db');
267 assert.equal(result.error, 'Relation db not found for wordpress/0');
268 done();
269 });
270 });
271 });
272
273 describe('FakeBackend.getCharm', function() {
274 it('rejects unauthenticated calls', function(done) {
275 fakebackend.logout();
276 fakebackend.getCharm('cs:wordpress', ERROR('Please log in.', done));
277 });
278
279 it('disallows malformed charm names', function(done) {
280 fakebackend.getCharm('^invalid', ERROR('Invalid charm id.', done));
281 });
282
283 it('successfully returns valid charms', function(done) {
284 fakebackend.getCharm('cs:wordpress', function(data) {
285 assert.equal(data.result.name, 'wordpress');
286 done();
287 });
288 });
289 });
290
291 describe('FakeBackend.getService', function() {
292 it('rejects unauthenticated calls', function() {
293 fakebackend.logout();
294 var result = fakebackend.getService('cs:wordpress');
295 assert.equal(result.error, 'Please log in.');
296 });
297
298 it('returns an error for a missing service', function() {
299 var result = fakebackend.getService('^invalid');
300 assert.equal(result.error, 'Invalid service id.');
301 });
302
303 it('successfully returns a valid service', function(done) {
304 fakebackend.deploy('cs:wordpress', function() {
305 var service = fakebackend.getService('wordpress').result;
306 assert.equal(service.name, 'wordpress');
307 done();
308 });
309 });
310 });
311
312 describe('FakeBackend.setConfig', function() {
313 it('rejects unauthenticated calls', function() {
314 fakebackend.logout();
315 var result = fakebackend.setConfig('wordpress', {'foo': 'bar'});
316 assert.equal(result.error, 'Please log in.');
317 });
318
319 it('returns an error for a missing service', function() {
320 var result = fakebackend.setConfig('scaling', {});
321 assert.equal(result.error, 'Service \"scaling\" does not exist.');
322 });
323
324 it('successfully returns a valid service configuration', function(done) {
325 fakebackend.deploy('cs:wordpress', function() {
326 fakebackend.setConfig('wordpress', {
327 'blog-title': 'Silence is Golden.'});
328 var service = fakebackend.getService('wordpress').result;
329 var config = service.config;
330 assert.equal(config['blog-title'], 'Silence is Golden.');
331 done();
332 });
333 });
334 });
335
336 describe('FakeBackend.setConstraints', function() {
337 it('rejects unauthenticated calls', function() {
338 fakebackend.logout();
339 var result = fakebackend.setConstraints('wordpress', {'cpu': '4'});
340 assert.equal(result.error, 'Please log in.');
341 });
342
343 it('returns an error for a missing service', function() {
344 var result = fakebackend.setConstraints('scaling', {});
345 assert.equal(result.error, 'Service \"scaling\" does not exist.');
346 });
347
348 it('successfully returns a valid constraints', function(done) {
349 fakebackend.deploy('cs:wordpress', function() {
350 fakebackend.setConstraints('wordpress', {'cpu': '4'});
351 var service = fakebackend.getService('wordpress').result;
352 var constraints = service.constraints;
353 assert.equal(constraints.cpu, '4');
354 assert.equal(constraints.mem, undefined);
355 done();
356 });
357 });
358
359 it('successfully returns a valid constraints as array', function(done) {
360 fakebackend.deploy('cs:wordpress', function() {
361 fakebackend.setConstraints('wordpress', ['cpu=4']);
362 var service = fakebackend.getService('wordpress').result;
363 var constraints = service.constraints;
364 assert.equal(constraints.cpu, '4');
365 assert.equal(constraints.mem, undefined);
366 done();
367 });
368 });
369 });
370
371 describe('FakeBackend.Annotations', function() {
372 it('must require authentication', function() {
373 fakebackend.logout();
374 var reply = fakebackend.getAnnotations('env');
375 assert.equal(reply.error, 'Please log in.');
376 });
377
378 it('must get annotations from a service', function(done) {
379 fakebackend.deploy('cs:wordpress', function() {
380 var service = fakebackend.getService('wordpress').result;
381 assert.equal(service.annotations, undefined);
382 var anno = fakebackend.getAnnotations('wordpress').result;
383 assert.equal(anno, undefined);
384 done();
385 });
386 });
387
388 it('must update annotations to a service', function(done) {
389 fakebackend.deploy('cs:wordpress', function() {
390 fakebackend.updateAnnotations('wordpress',
391 {'foo': 'bar', 'gone': 'away'});
392 var anno = fakebackend.getAnnotations('wordpress').result;
393 assert.equal(anno.foo, 'bar');
394 assert.equal(anno.gone, 'away');
395
396 // Apply an update and verify that merge happened.
397 fakebackend.updateAnnotations('wordpress', {'gone': 'too far'});
398 anno = fakebackend.getAnnotations('wordpress').result;
399 assert.equal(anno.foo, 'bar');
400 assert.equal(anno.gone, 'too far');
401 done();
402 });
403 });
404
405 it('must update annotations on a unit', function(done) {
406 fakebackend.deploy('cs:wordpress', function() {
407 fakebackend.updateAnnotations('wordpress/0',
408 {'foo': 'bar', 'gone': 'away'});
409 var anno = fakebackend.getAnnotations('wordpress/0').result;
410 assert.equal(anno.foo, 'bar');
411 assert.equal(anno.gone, 'away');
412
413 // Apply an update and verify that merge happened.
414 fakebackend.updateAnnotations('wordpress/0', {'gone': 'too far'});
415 anno = fakebackend.getAnnotations('wordpress/0').result;
416 assert.equal(anno.foo, 'bar');
417 assert.equal(anno.gone, 'too far');
418 done();
419 });
420 });
421
422 it('must update annotations on the environment', function() {
423 fakebackend.updateAnnotations('env',
424 {'foo': 'bar', 'gone': 'away'});
425 var anno = fakebackend.getAnnotations('env').result;
426 assert.equal(anno.foo, 'bar');
427 assert.equal(anno.gone, 'away');
428
429 // Apply an update and verify that merge happened.
430 fakebackend.updateAnnotations('env', {'gone': 'too far'});
431 anno = fakebackend.getAnnotations('env').result;
432 assert.equal(anno.foo, 'bar');
433 assert.equal(anno.gone, 'too far');
434
435 // Verify the annotations on the model directly.
436 anno = fakebackend.db.environment.get('annotations');
437 assert.equal(anno.foo, 'bar');
438 assert.equal(anno.gone, 'too far');
439
440 // Verify changes name it into nextAnnotations
441 var changes = fakebackend.nextAnnotations();
442 assert.deepEqual(changes.annotations.env,
443 [fakebackend.db.environment, true]);
444 });
445
446 it('must remove annotations from a service', function(done) {
447 fakebackend.deploy('cs:wordpress', function() {
448 fakebackend.updateAnnotations('wordpress',
449 {'foo': 'bar', 'gone': 'away'});
450 var anno = fakebackend.getAnnotations('wordpress').result;
451 assert.equal(anno.foo, 'bar');
452 assert.equal(anno.gone, 'away');
453
454 // Remove an annotation and verify that happened.
455 fakebackend.removeAnnotations('wordpress', ['gone']);
456 anno = fakebackend.getAnnotations('wordpress').result;
457 assert.equal(anno.foo, 'bar');
458 assert.equal(anno.gone, undefined);
459
460 // Finally remove annotations with falsey keys.
461 fakebackend.removeAnnotations('wordpress');
462 anno = fakebackend.getAnnotations('wordpress').result;
463 assert.deepEqual(anno, {});
464 done();
465 });
466
467 });
468 });
218 }); 469 });
219 470
220 describe('FakeBackend.addUnit', function() { 471 describe('FakeBackend.addUnit', function() {
221 var requires = [ 472 var requires = [
222 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models']; 473 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models'];
223 var Y, fakebackend, utils, setCharm, deployResult, callback; 474 var Y, fakebackend, utils, setCharm, deployResult, callback;
224 475
225 before(function(done) { 476 before(function(done) {
226 Y = YUI(GlobalConfig).use(requires, function(Y) { 477 Y = YUI(GlobalConfig).use(requires, function(Y) {
227 utils = Y.namespace('juju-tests.utils'); 478 utils = Y.namespace('juju-tests.utils');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 it('defaults to adding just one unit', function() { 521 it('defaults to adding just one unit', function() {
271 fakebackend.deploy('cs:wordpress', callback); 522 fakebackend.deploy('cs:wordpress', callback);
272 assert.isUndefined(deployResult.error); 523 assert.isUndefined(deployResult.error);
273 assert.lengthOf( 524 assert.lengthOf(
274 fakebackend.db.units.get_units_for_service(deployResult.service), 1); 525 fakebackend.db.units.get_units_for_service(deployResult.service), 1);
275 var result = fakebackend.addUnit('wordpress'); 526 var result = fakebackend.addUnit('wordpress');
276 assert.lengthOf(result.units, 1); 527 assert.lengthOf(result.units, 1);
277 assert.lengthOf( 528 assert.lengthOf(
278 fakebackend.db.units.get_units_for_service(deployResult.service), 2); 529 fakebackend.db.units.get_units_for_service(deployResult.service), 2);
279 // Units are simple objects, not models. 530 // Units are simple objects, not models.
280 assert.equal(result.units[0].id, 'wordpress/2'); 531 assert.equal(result.units[0].id, 'wordpress/1');
281 assert.equal(result.units[0].agent_state, 'started'); 532 assert.equal(result.units[0].agent_state, 'started');
282 assert.deepEqual( 533 assert.deepEqual(
283 result.units[0], fakebackend.db.units.getById('wordpress/2')); 534 result.units[0], fakebackend.db.units.getById('wordpress/1'));
284 // Creating units also created/assigned associated machines. Like units, 535 // Creating units also created/assigned associated machines. Like units,
285 // these are simple objects, not models. 536 // these are simple objects, not models.
286 assert.lengthOf(result.machines, 1); 537 assert.lengthOf(result.machines, 1);
287 assert.equal( 538 assert.equal(
288 result.machines[0].machine_id, result.units[0].machine); 539 result.machines[0].machine_id, result.units[0].machine);
289 assert.isString(result.machines[0].machine_id); 540 assert.isString(result.machines[0].machine_id);
290 assert.isString(result.machines[0].public_address); 541 assert.isString(result.machines[0].public_address);
291 assert.match( 542 assert.match(
292 result.machines[0].public_address, /^[^.]+\.example\.com$/); 543 result.machines[0].public_address, /^[^.]+\.example\.com$/);
293 assert.equal(result.machines[0].agent_state, 'running'); 544 assert.equal(result.machines[0].agent_state, 'running');
294 assert.equal(result.machines[0].instance_state, 'running');
295 }); 545 });
296 546
297 it('adds multiple units', function() { 547 it('adds multiple units', function() {
298 fakebackend.deploy('cs:wordpress', callback); 548 fakebackend.deploy('cs:wordpress', callback);
299 assert.isUndefined(deployResult.error); 549 assert.isUndefined(deployResult.error);
300 assert.lengthOf( 550 assert.lengthOf(
301 fakebackend.db.units.get_units_for_service(deployResult.service), 1); 551 fakebackend.db.units.get_units_for_service(deployResult.service), 1);
302 var result = fakebackend.addUnit('wordpress', 5); 552 var result = fakebackend.addUnit('wordpress', 5);
303 assert.lengthOf(result.units, 5); 553 assert.lengthOf(result.units, 5);
304 assert.lengthOf( 554 assert.lengthOf(
305 fakebackend.db.units.get_units_for_service(deployResult.service), 6); 555 fakebackend.db.units.get_units_for_service(deployResult.service), 6);
306 assert.equal(result.units[0].id, 'wordpress/2'); 556 assert.equal(result.units[0].id, 'wordpress/1');
307 assert.equal(result.units[1].id, 'wordpress/3'); 557 assert.equal(result.units[1].id, 'wordpress/2');
308 assert.equal(result.units[2].id, 'wordpress/4'); 558 assert.equal(result.units[2].id, 'wordpress/3');
309 assert.equal(result.units[3].id, 'wordpress/5'); 559 assert.equal(result.units[3].id, 'wordpress/4');
310 assert.equal(result.units[4].id, 'wordpress/6'); 560 assert.equal(result.units[4].id, 'wordpress/5');
311 assert.lengthOf(result.machines, 5); 561 assert.lengthOf(result.machines, 5);
312 }); 562 });
313 563
314 }); 564 });
315 565
316 describe('FakeBackend.nextChanges', function() { 566 describe('FakeBackend.next*', function() {
317 var requires = [ 567 var requires = [
318 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models']; 568 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models'];
319 var Y, fakebackend, utils, setCharm, deployResult, callback; 569 var Y, fakebackend, utils, setCharm, deployResult, callback;
320 570
321 before(function(done) { 571 before(function(done) {
322 Y = YUI(GlobalConfig).use(requires, function(Y) { 572 Y = YUI(GlobalConfig).use(requires, function(Y) {
323 utils = Y.namespace('juju-tests.utils'); 573 utils = Y.namespace('juju-tests.utils');
324 done(); 574 done();
325 }); 575 });
326 }); 576 });
327 577
328 beforeEach(function() { 578 beforeEach(function() {
329 var setupData = utils.makeFakeBackendWithCharmStore(); 579 var setupData = utils.makeFakeBackendWithCharmStore();
330 fakebackend = setupData.fakebackend; 580 fakebackend = setupData.fakebackend;
331 setCharm = setupData.setCharm; 581 setCharm = setupData.setCharm;
332 deployResult = undefined; 582 deployResult = undefined;
333 callback = function(response) { deployResult = response; }; 583 callback = function(response) { deployResult = response; };
334 }); 584 });
335 585
336 afterEach(function() { 586 afterEach(function() {
337 fakebackend.destroy(); 587 fakebackend.destroy();
338 }); 588 });
339 589
340 it('rejects unauthenticated calls.', function() { 590 describe('FakeBackend.nextChanges', function() {
341 fakebackend.logout(); 591 it('rejects unauthenticated calls.', function() {
342 var result = fakebackend.nextChanges(); 592 fakebackend.logout();
343 assert.equal(result.error, 'Please log in.'); 593 var result = fakebackend.nextChanges();
344 }); 594 assert.equal(result.error, 'Please log in.');
345 595 });
346 it('reports no changes initially.', function() { 596
347 assert.isNull(fakebackend.nextChanges()); 597 it('reports no changes initially.', function() {
348 }); 598 assert.isNull(fakebackend.nextChanges());
349 599 });
350 it('reports a call to addUnit correctly.', function() { 600
351 fakebackend.deploy('cs:wordpress', callback); 601 it('reports a call to addUnit correctly.', function() {
352 assert.isUndefined(deployResult.error); 602 fakebackend.deploy('cs:wordpress', callback);
353 assert.isObject(fakebackend.nextChanges()); 603 assert.isUndefined(deployResult.error);
354 var result = fakebackend.addUnit('wordpress'); 604 assert.isObject(fakebackend.nextChanges());
355 assert.lengthOf(result.units, 1); 605 var result = fakebackend.addUnit('wordpress');
356 var changes = fakebackend.nextChanges(); 606 assert.lengthOf(result.units, 1);
357 assert.lengthOf(Y.Object.keys(changes.services), 0); 607 var changes = fakebackend.nextChanges();
358 assert.lengthOf(Y.Object.keys(changes.units), 1); 608 assert.lengthOf(Y.Object.keys(changes.services), 0);
359 assert.lengthOf(Y.Object.keys(changes.machines), 1); 609 assert.lengthOf(Y.Object.keys(changes.units), 1);
360 assert.lengthOf(Y.Object.keys(changes.relations), 0); 610 assert.lengthOf(Y.Object.keys(changes.machines), 1);
361 assert.deepEqual( 611 assert.lengthOf(Y.Object.keys(changes.relations), 0);
362 changes.units['wordpress/2'], [result.units[0], true]); 612 assert.deepEqual(
363 assert.deepEqual( 613 changes.units['wordpress/1'], [result.units[0], true]);
364 changes.machines[result.machines[0].machine_id], 614 assert.deepEqual(
365 [result.machines[0], true]); 615 changes.machines[result.machines[0].machine_id],
366 }); 616 [result.machines[0], true]);
367 617 });
368 it('reports a deploy correctly.', function() { 618
369 fakebackend.deploy('cs:wordpress', callback); 619 it('reports a deploy correctly.', function() {
370 assert.isUndefined(deployResult.error); 620 fakebackend.deploy('cs:wordpress', callback);
371 var changes = fakebackend.nextChanges(); 621 assert.isUndefined(deployResult.error);
372 assert.lengthOf(Y.Object.keys(changes.services), 1); 622 var changes = fakebackend.nextChanges();
373 assert.deepEqual( 623 assert.lengthOf(Y.Object.keys(changes.services), 1);
374 changes.services.wordpress, [deployResult.service, true]); 624 assert.deepEqual(
375 assert.lengthOf(Y.Object.keys(changes.units), 1); 625 changes.services.wordpress, [deployResult.service, true]);
376 assert.deepEqual( 626 assert.lengthOf(Y.Object.keys(changes.units), 1);
377 changes.units['wordpress/1'], [deployResult.units[0], true]); 627 assert.deepEqual(
378 assert.lengthOf(Y.Object.keys(changes.machines), 1); 628 changes.units['wordpress/0'], [deployResult.units[0], true]);
379 assert.deepEqual( 629 assert.lengthOf(Y.Object.keys(changes.machines), 1);
380 changes.machines[deployResult.machines[0].machine_id], 630 assert.deepEqual(
381 [deployResult.machines[0], true]); 631 changes.machines[deployResult.machines[0].machine_id],
382 assert.lengthOf(Y.Object.keys(changes.relations), 0); 632 [deployResult.machines[0], true]);
383 }); 633 assert.lengthOf(Y.Object.keys(changes.relations), 0);
384 634 });
385 it('reports a deploy of multiple units correctly.', function() { 635
386 fakebackend.deploy('cs:wordpress', callback, {unitCount: 5}); 636 it('reports a deploy of multiple units correctly.', function() {
387 assert.isUndefined(deployResult.error); 637 fakebackend.deploy('cs:wordpress', callback, {unitCount: 5});
388 var changes = fakebackend.nextChanges(); 638 assert.isUndefined(deployResult.error);
389 assert.lengthOf(Y.Object.keys(changes.services), 1); 639 var changes = fakebackend.nextChanges();
390 assert.lengthOf(Y.Object.keys(changes.units), 5); 640 assert.lengthOf(Y.Object.keys(changes.services), 1);
391 assert.lengthOf(Y.Object.keys(changes.machines), 5); 641 assert.lengthOf(Y.Object.keys(changes.units), 5);
392 assert.lengthOf(Y.Object.keys(changes.relations), 0); 642 assert.lengthOf(Y.Object.keys(changes.machines), 5);
393 }); 643 assert.lengthOf(Y.Object.keys(changes.relations), 0);
394 644 });
395 it('reports no changes when no changes have occurred since the last call.', 645
396 function() { 646 it('reports no changes when no changes have occurred.',
397 fakebackend.deploy('cs:wordpress', callback); 647 function() {
398 assert.isUndefined(deployResult.error); 648 fakebackend.deploy('cs:wordpress', callback);
399 assert.isObject(fakebackend.nextChanges()); 649 assert.isUndefined(deployResult.error);
400 assert.isNull(fakebackend.nextChanges()); 650 assert.isObject(fakebackend.nextChanges());
401 } 651 assert.isNull(fakebackend.nextChanges());
402 ); 652 }
403 653 );
654 });
655
656 describe('FakeBackend.nextAnnotations', function() {
657 it('rejects unauthenticated calls.', function() {
658 fakebackend.logout();
659 var result = fakebackend.nextAnnotations();
660 assert.equal(result.error, 'Please log in.');
661 });
662
663 it('reports no changes initially.', function() {
664 assert.isNull(fakebackend.nextAnnotations());
665 });
666
667 it('reports service changes correctly', function(done) {
668 fakebackend.deploy('cs:wordpress', function() {
669 fakebackend.updateAnnotations('wordpress',
670 {'foo': 'bar', 'gone': 'away'});
671
672 var changes = fakebackend.nextAnnotations();
673 assert.deepEqual(changes.services.wordpress,
674 [fakebackend.db.services.getById('wordpress'),
675 true]);
676 done();
677 });
678 });
679
680 it('reports env changes correctly', function() {
681 fakebackend.updateAnnotations('env',
682 {'foo': 'bar', 'gone': 'away'});
683
684 // Verify changes name it into nextAnnotations
685 var changes = fakebackend.nextAnnotations();
686 assert.deepEqual(changes.annotations.env,
687 [fakebackend.db.environment, true]);
688 });
689 });
404 }); 690 });
405 691
406 describe('FakeBackend.addRelation', function() { 692 describe('FakeBackend.addRelation', function() {
407 var requires = [ 693 var requires = [
408 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models']; 694 'node', 'juju-tests-utils', 'juju-models', 'juju-charm-models'];
409 var Y, fakebackend, utils, setCharm, deployResult, callback; 695 var Y, fakebackend, utils, setCharm, deployResult, callback;
410 696
411 before(function(done) { 697 before(function(done) {
412 Y = YUI(GlobalConfig).use(requires, function(Y) { 698 Y = YUI(GlobalConfig).use(requires, function(Y) {
413 utils = Y.namespace('juju-tests.utils'); 699 utils = Y.namespace('juju-tests.utils');
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 it('can create a relation with an inferred subordinate charm', function() { 771 it('can create a relation with an inferred subordinate charm', function() {
486 // TODO 772 // TODO
487 }); 773 });
488 774
489 it('can create a relation with an inferred interface', function() { 775 it('can create a relation with an inferred interface', function() {
490 // TODO 776 // TODO
491 }); 777 });
492 778
493 779
494 }); 780 });
781
495 })(); 782 })();
LEFTRIGHT

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