joyent/node-triton#221 cli-image-create.test.js crashes if image creation isn't work

This commit is contained in:
Trent Mick 2017-08-08 16:58:26 -07:00
parent 9d8681a21b
commit c7bb6b01e1

View File

@ -165,6 +165,7 @@ test('triton image ...', testOpts, function (tt) {
var argv = ['image', 'create', '-j', '-w', '-t', 'foo=bar',
originInst.id, IMAGE_DATA.name, IMAGE_DATA.version];
h.safeTriton(t, argv, function (err, stdout) {
if (!err) {
var lines = h.jsonStreamParse(stdout);
img = lines[1];
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.state, 'active', 'img.state is active');
t.equal(img.origin, originInst.image, 'img.origin');
}
t.end();
});
});
var derivedInst;
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];
h.safeTriton(t, argv, function (err, stdout) {
if (!err) {
var lines = h.jsonStreamParse(stdout);
derivedInst = lines[1];
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();
});
} else {
t.end();
}
});
// 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
// really long time.
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],
function () {
t.end();
@ -203,6 +217,10 @@ test('triton image ...', testOpts, function (tt) {
});
tt.test(' cleanup: triton image rm', function (t) {
if (!img) {
t.end();
return;
}
h.safeTriton(t, ['image', 'rm', '-f', img.id], function () {
t.end();
});