joyent/node-triton#221 cli-image-create.test.js crashes if image creation isn't work
This commit is contained in:
		
							parent
							
								
									9d8681a21b
								
							
						
					
					
						commit
						c7bb6b01e1
					
				| @ -165,6 +165,7 @@ test('triton image ...', testOpts, function (tt) { | |||||||
|         var argv = ['image', 'create', '-j', '-w', '-t', 'foo=bar', |         var argv = ['image', 'create', '-j', '-w', '-t', 'foo=bar', | ||||||
|             originInst.id, IMAGE_DATA.name, IMAGE_DATA.version]; |             originInst.id, IMAGE_DATA.name, IMAGE_DATA.version]; | ||||||
|         h.safeTriton(t, argv, function (err, stdout) { |         h.safeTriton(t, argv, function (err, stdout) { | ||||||
|  |             if (!err) { | ||||||
|                 var lines = h.jsonStreamParse(stdout); |                 var lines = h.jsonStreamParse(stdout); | ||||||
|                 img = lines[1]; |                 img = lines[1]; | ||||||
|                 t.ok(img, 'created image, id=' + img.id); |                 t.ok(img, 'created image, id=' + img.id); | ||||||
| @ -173,20 +174,29 @@ test('triton image ...', testOpts, function (tt) { | |||||||
|                 t.equal(img.public, false, 'img.public is false'); |                 t.equal(img.public, false, 'img.public is false'); | ||||||
|                 t.equal(img.state, 'active', 'img.state is active'); |                 t.equal(img.state, 'active', 'img.state is active'); | ||||||
|                 t.equal(img.origin, originInst.image, 'img.origin'); |                 t.equal(img.origin, originInst.image, 'img.origin'); | ||||||
|  |             } | ||||||
|             t.end(); |             t.end(); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     var derivedInst; |     var derivedInst; | ||||||
|     tt.test('  triton create ... -n ' + DERIVED_ALIAS, function (t) { |     tt.test('  triton create ... -n ' + DERIVED_ALIAS, function (t) { | ||||||
|  |         t.ok(img, 'have an img to test'); | ||||||
|  |         if (img) { | ||||||
|             var argv = ['create', '-wj', '-n', DERIVED_ALIAS, img.id, pkgId]; |             var argv = ['create', '-wj', '-n', DERIVED_ALIAS, img.id, pkgId]; | ||||||
|             h.safeTriton(t, argv, function (err, stdout) { |             h.safeTriton(t, argv, function (err, stdout) { | ||||||
|  |                 if (!err) { | ||||||
|                     var lines = h.jsonStreamParse(stdout); |                     var lines = h.jsonStreamParse(stdout); | ||||||
|                     derivedInst = lines[1]; |                     derivedInst = lines[1]; | ||||||
|                     t.ok(derivedInst.id, 'derivedInst.id: ' + derivedInst.id); |                     t.ok(derivedInst.id, 'derivedInst.id: ' + derivedInst.id); | ||||||
|             t.equal(lines[1].state, 'running', 'derivedInst is running'); |                     t.equal(lines[1].state, 'running', | ||||||
|  |                         'derivedInst is running'); | ||||||
|  |                 } | ||||||
|                 t.end(); |                 t.end(); | ||||||
|             }); |             }); | ||||||
|  |         } else { | ||||||
|  |             t.end(); | ||||||
|  |         } | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // TODO: Once have `triton ssh ...` working in test suite without hangs,
 |     // TODO: Once have `triton ssh ...` working in test suite without hangs,
 | ||||||
| @ -196,6 +206,10 @@ test('triton image ...', testOpts, function (tt) { | |||||||
|     // have a way to know if the attempt failed or if it is just taking a
 |     // have a way to know if the attempt failed or if it is just taking a
 | ||||||
|     // really long time.
 |     // really long time.
 | ||||||
|     tt.test('  cleanup: triton rm', {timeout: 10 * 60 * 1000}, function (t) { |     tt.test('  cleanup: triton rm', {timeout: 10 * 60 * 1000}, function (t) { | ||||||
|  |         if (!originInst || !derivedInst) { | ||||||
|  |             t.end(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|         h.safeTriton(t, ['rm', '-w', originInst.id, derivedInst.id], |         h.safeTriton(t, ['rm', '-w', originInst.id, derivedInst.id], | ||||||
|                 function () { |                 function () { | ||||||
|             t.end(); |             t.end(); | ||||||
| @ -203,6 +217,10 @@ test('triton image ...', testOpts, function (tt) { | |||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     tt.test('  cleanup: triton image rm', function (t) { |     tt.test('  cleanup: triton image rm', function (t) { | ||||||
|  |         if (!img) { | ||||||
|  |             t.end(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|         h.safeTriton(t, ['image', 'rm', '-f', img.id], function () { |         h.safeTriton(t, ['image', 'rm', '-f', img.id], function () { | ||||||
|             t.end(); |             t.end(); | ||||||
|         }); |         }); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user