2015-09-01 10:31:00 +03:00
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2016-02-03 08:03:01 +02:00
|
|
|
* Copyright 2016, Joyent, Inc.
|
2015-09-01 10:31:00 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Integration tests for `triton account`
|
|
|
|
*/
|
|
|
|
|
|
|
|
var h = require('./helpers');
|
|
|
|
var test = require('tape');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --- Globals
|
|
|
|
|
2016-01-15 08:56:38 +02:00
|
|
|
var writeTestOpts = {
|
|
|
|
skip: !h.CONFIG.allowWriteActions
|
|
|
|
};
|
2015-09-01 10:31:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
// --- Tests
|
|
|
|
|
|
|
|
test('triton account', function (tt) {
|
|
|
|
|
|
|
|
tt.test(' triton account -h', function (t) {
|
|
|
|
h.triton('account -h', function (err, stdout, stderr) {
|
|
|
|
if (h.ifErr(t, err))
|
|
|
|
return t.end();
|
2015-09-22 20:55:42 +03:00
|
|
|
t.ok(/Usage:\s+triton account/.test(stdout), 'account usage');
|
2015-09-01 10:31:00 +03:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tt.test(' triton help account', function (t) {
|
|
|
|
h.triton('help account', function (err, stdout, stderr) {
|
|
|
|
if (h.ifErr(t, err))
|
|
|
|
return t.end();
|
2015-09-22 20:55:42 +03:00
|
|
|
t.ok(/Usage:\s+triton account/.test(stdout), 'account usage');
|
2015-09-01 10:31:00 +03:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-01-08 21:07:43 +02:00
|
|
|
tt.test(' triton account get', function (t) {
|
2016-02-03 08:03:01 +02:00
|
|
|
h.triton('-v account get', function (err, stdout, stderr) {
|
2015-09-01 10:31:00 +03:00
|
|
|
if (h.ifErr(t, err))
|
|
|
|
return t.end();
|
2015-10-07 09:09:52 +03:00
|
|
|
t.ok(new RegExp(
|
|
|
|
'^login: ' + h.CONFIG.profile.account, 'm').test(stdout));
|
2015-09-01 10:31:00 +03:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-01-15 08:56:38 +02:00
|
|
|
var account;
|
2016-01-08 21:07:43 +02:00
|
|
|
tt.test(' triton account get -j', function (t) {
|
|
|
|
h.triton('account get -j', function (err, stdout, stderr) {
|
2015-09-01 10:31:00 +03:00
|
|
|
if (h.ifErr(t, err))
|
|
|
|
return t.end();
|
2016-01-15 08:56:38 +02:00
|
|
|
account = JSON.parse(stdout);
|
2015-10-07 09:09:52 +03:00
|
|
|
t.equal(account.login, h.CONFIG.profile.account, 'account.login');
|
2015-09-01 10:31:00 +03:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
2016-01-15 08:56:38 +02:00
|
|
|
|
|
|
|
tt.test(' triton account update foo=bar', writeTestOpts, function (t) {
|
|
|
|
h.triton('account update foo=bar', function (err, stdout, stderr) {
|
|
|
|
t.ok(err);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tt.test(' triton account update companyName=foo', writeTestOpts,
|
|
|
|
function (t) {
|
|
|
|
h.triton('account update companyName=foo', function (err, _o, _e) {
|
|
|
|
if (h.ifErr(t, err))
|
|
|
|
return t.end();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Limitation: because x-dc replication, the update might not be
|
|
|
|
* reflected in a get right away.
|
|
|
|
* TODO: poll 'account get' until a timeout, or implement that
|
|
|
|
* with 'triton account update -w' and use that.
|
|
|
|
*/
|
|
|
|
//h.triton('account get -j', function (err2, stdout, stderr) {
|
|
|
|
// if (h.ifErr(t, err2))
|
|
|
|
// return t.end();
|
|
|
|
// var updatedAccount = JSON.parse(stdout);
|
|
|
|
// t.equal(updatedAccount.companyName, 'foo',
|
|
|
|
// '<updated account>.companyName');
|
|
|
|
// t.end();
|
|
|
|
//});
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tt.test(' triton account update companyName=<oldvalue>', writeTestOpts,
|
|
|
|
function (t) {
|
|
|
|
h.triton('account update companyName=' + account.companyName || '',
|
|
|
|
function (err, _o, _e) {
|
|
|
|
if (h.ifErr(t, err))
|
|
|
|
return t.end();
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
2015-09-01 10:31:00 +03:00
|
|
|
});
|