This repository has been archived on 2020-01-20. You can view files and clone it, but cannot push or open issues or pull requests.
node-spearhead/test/integration/cli-profiles.test.js

87 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-09-29 21:45:52 +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/.
*/
/*
* Copyright (c) 2015, Joyent, Inc.
*/
/*
* Test 'profiles' and 'profile'
*/
var fs = require('fs');
var path = require('path');
var h = require('./helpers');
var test = require('tape');
var PROFILE_FILE = path.join(__dirname, 'test-profile.json');
var PROFILE_DATA = JSON.parse(fs.readFileSync(PROFILE_FILE, 'utf8'));
var opts = {
skip: !h.CONFIG.allowWriteActions
2015-09-29 21:45:52 +03:00
};
//
2015-09-29 21:45:52 +03:00
// --- Tests
if (opts.skip) {
console.error('** skipping %s tests', __filename);
console.error('** set "allowWriteActions" in test config to enable');
2015-09-29 21:45:52 +03:00
}
test('triton profiles (read only)', function (tt) {
tt.test(' triton profile env', function (t) {
2015-09-29 21:45:52 +03:00
h.safeTriton(t, {json: true, args: ['profile', '-j', 'env']},
function (p) {
t.equal(p.account, h.CONFIG.profile.account,
2015-09-29 21:45:52 +03:00
'env account correct');
t.equal(p.keyId, h.CONFIG.profile.keyId,
2015-09-29 21:45:52 +03:00
'env keyId correct');
t.equal(p.url, h.CONFIG.profile.url,
2015-09-29 21:45:52 +03:00
'env url correct');
t.end();
});
});
tt.end();
});
test('triton profiles (read/write)', opts, function (tt) {
tt.test(' triton profile create', function (t) {
2015-09-29 21:45:52 +03:00
h.safeTriton(t, ['profile', '-a', PROFILE_FILE],
function (stdout) {
t.ok(stdout.match(/^Saved profile/), 'stdout correct');
t.end();
});
});
tt.test(' triton profile get', function (t) {
2015-09-29 21:45:52 +03:00
h.safeTriton(t,
{json: true, args: ['profile', '-j', PROFILE_DATA.name]},
function (p) {
t.deepEqual(p, PROFILE_DATA, 'profile matched');
t.end();
});
});
tt.test(' triton profile delete', function (t) {
2015-09-29 21:45:52 +03:00
h.safeTriton(t, ['profile', '-df', PROFILE_DATA.name],
function (stdout) {
t.ok(stdout.match(/^Deleted profile/), 'stdout correct');
t.end();
});
});
tt.end();
});