* Move CLI tests to Jest * Get rid of logs from the output * Allow skipped tests * Move integration tests into integration_tests folder
This commit is contained in:
parent
b23b7e2817
commit
ed63f6d5a0
|
@ -11,7 +11,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
rules: {
|
||||
'jest/no-disabled-tests': 'error',
|
||||
'jest/no-focused-tests': 'error',
|
||||
'jest/no-identical-title': 'error',
|
||||
},
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import { set } from 'lodash';
|
||||
import BasePathProxy from '../base_path_proxy';
|
||||
import BasePathProxy from './base_path_proxy';
|
||||
|
||||
describe('CLI Cluster Manager', function () {
|
||||
describe('base_path_proxy constructor', function () {
|
||||
|
@ -10,7 +9,7 @@ describe('CLI Cluster Manager', function () {
|
|||
set(settings, 'server.ssl.certificate', './cert.crt');
|
||||
set(settings, 'server.ssl.key', './cert.key');
|
||||
|
||||
expect(() => new BasePathProxy(null, settings)).to.throwError(
|
||||
expect(() => new BasePathProxy(null, settings)).toThrow(
|
||||
`Invalid Configuration: please specify either "server.ssl.keystore.path" or "server.ssl.certificate", not both.`
|
||||
);
|
||||
});
|
|
@ -1,10 +1,9 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import cluster from 'cluster';
|
||||
import { sample } from 'lodash';
|
||||
|
||||
import ClusterManager from '../cluster_manager';
|
||||
import Worker from '../worker';
|
||||
import ClusterManager from './cluster_manager';
|
||||
import Worker from './worker';
|
||||
|
||||
describe('CLI cluster manager', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
@ -30,11 +29,11 @@ describe('CLI cluster manager', function () {
|
|||
it('has two workers', function () {
|
||||
const manager = new ClusterManager({});
|
||||
|
||||
expect(manager.workers).to.have.length(2);
|
||||
for (const worker of manager.workers) expect(worker).to.be.a(Worker);
|
||||
expect(manager.workers).toHaveLength(2);
|
||||
for (const worker of manager.workers) expect(worker).toBeInstanceOf(Worker);
|
||||
|
||||
expect(manager.optimizer).to.be.a(Worker);
|
||||
expect(manager.server).to.be.a(Worker);
|
||||
expect(manager.optimizer).toBeInstanceOf(Worker);
|
||||
expect(manager.server).toBeInstanceOf(Worker);
|
||||
});
|
||||
|
||||
it('delivers broadcast messages to other workers', function () {
|
||||
|
@ -51,9 +50,9 @@ describe('CLI cluster manager', function () {
|
|||
messenger.emit('broadcast', football);
|
||||
for (const worker of manager.workers) {
|
||||
if (worker === messenger) {
|
||||
expect(worker.fork.send.callCount).to.be(0);
|
||||
expect(worker.fork.send.callCount).toBe(0);
|
||||
} else {
|
||||
expect(worker.fork.send.firstCall.args[0]).to.be(football);
|
||||
expect(worker.fork.send.firstCall.args[0]).toBe(football);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,11 +1,10 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import cluster from 'cluster';
|
||||
import { findIndex } from 'lodash';
|
||||
|
||||
import MockClusterFork from './_mock_cluster_fork';
|
||||
import Worker from '../worker';
|
||||
import Log from '../../log';
|
||||
import Worker from './worker';
|
||||
import Log from '../log';
|
||||
|
||||
const workersToShutdown = [];
|
||||
|
||||
|
@ -52,7 +51,7 @@ describe('CLI cluster manager', function () {
|
|||
const worker = setup({ watch: true });
|
||||
sinon.stub(worker, 'start');
|
||||
worker.onChange('/some/path');
|
||||
expect(worker.changes).to.eql(['/some/path']);
|
||||
expect(worker.changes).toEqual(['/some/path']);
|
||||
sinon.assert.calledOnce(worker.start);
|
||||
});
|
||||
});
|
||||
|
@ -62,7 +61,7 @@ describe('CLI cluster manager', function () {
|
|||
const worker = setup({ watch: false });
|
||||
sinon.stub(worker, 'start');
|
||||
worker.onChange('/some/path');
|
||||
expect(worker.changes).to.eql([]);
|
||||
expect(worker.changes).toEqual([]);
|
||||
sinon.assert.notCalled(worker.start);
|
||||
});
|
||||
});
|
||||
|
@ -73,7 +72,7 @@ describe('CLI cluster manager', function () {
|
|||
it('kills the worker and unbinds from message, online, and disconnect events', async function () {
|
||||
const worker = setup({ log: new Log(false, true) });
|
||||
await worker.start();
|
||||
expect(worker).to.have.property('online', true);
|
||||
expect(worker).toHaveProperty('online', true);
|
||||
const fork = worker.fork;
|
||||
sinon.assert.notCalled(fork.process.kill);
|
||||
assertListenerAdded(fork, 'message');
|
||||
|
@ -139,9 +138,9 @@ describe('CLI cluster manager', function () {
|
|||
it('sets the listening flag and emits the listening event', function () {
|
||||
const worker = setup();
|
||||
const stub = sinon.stub(worker, 'emit');
|
||||
expect(worker).to.have.property('listening', false);
|
||||
expect(worker).toHaveProperty('listening', false);
|
||||
worker.onMessage('WORKER_LISTENING');
|
||||
expect(worker).to.have.property('listening', true);
|
||||
expect(worker).toHaveProperty('listening', true);
|
||||
sinon.assert.calledWithExactly(stub, 'listening');
|
||||
});
|
||||
});
|
|
@ -1,39 +0,0 @@
|
|||
import { spawnSync } from 'child_process';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import expect from 'expect.js';
|
||||
|
||||
const ROOT_DIR = resolve(__dirname, '../../../../');
|
||||
const INVALID_CONFIG_PATH = resolve(__dirname, 'fixtures/invalid_config.yml');
|
||||
|
||||
describe('cli invalid config support', function () {
|
||||
this.timeout(20 * 1000);
|
||||
this.slow(10 * 1000);
|
||||
|
||||
it('exits with statusCode 64 and logs a single line when config is invalid', function () {
|
||||
const { error, status, stdout } = spawnSync(process.execPath, [
|
||||
'src/cli',
|
||||
'--config', INVALID_CONFIG_PATH
|
||||
], {
|
||||
cwd: ROOT_DIR
|
||||
});
|
||||
|
||||
const logLines = stdout.toString('utf8')
|
||||
.split('\n')
|
||||
.filter(Boolean)
|
||||
.map(JSON.parse);
|
||||
|
||||
expect(error).to.be(undefined);
|
||||
expect(status).to.be(64);
|
||||
|
||||
expect(logLines).to.have.length(1);
|
||||
expect(logLines[0]).to.have.property('tags')
|
||||
.eql(['fatal']);
|
||||
expect(logLines[0]).to.have.property('message')
|
||||
.contain('"unknown.key"')
|
||||
.contain('"other.unknown.key"')
|
||||
.contain('"other.third"')
|
||||
.contain('"some.flat.key"')
|
||||
.contain('"some.array"');
|
||||
});
|
||||
});
|
|
@ -1,95 +0,0 @@
|
|||
import { spawn } from 'child_process';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { relative, resolve } from 'path';
|
||||
import { safeDump } from 'js-yaml';
|
||||
import es from 'event-stream';
|
||||
import { readYamlConfig } from '../read_yaml_config';
|
||||
import expect from 'expect.js';
|
||||
|
||||
const testConfigFile = follow(`fixtures/reload_logging_config/kibana.test.yml`);
|
||||
const cli = follow(`../../../../bin/kibana`);
|
||||
|
||||
function follow(file) {
|
||||
return relative(process.cwd(), resolve(__dirname, file));
|
||||
}
|
||||
|
||||
function setLoggingJson(enabled) {
|
||||
const conf = readYamlConfig(testConfigFile);
|
||||
conf.logging = conf.logging || {};
|
||||
conf.logging.json = enabled;
|
||||
const yaml = safeDump(conf);
|
||||
writeFileSync(testConfigFile, yaml);
|
||||
return conf;
|
||||
}
|
||||
|
||||
describe(`Server logging configuration`, function () {
|
||||
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
if (isWindows) {
|
||||
it('SIGHUP is not a feature of Windows.');
|
||||
} else {
|
||||
it(`should be reloadable via SIGHUP process signaling`, function (done) {
|
||||
this.timeout(60000);
|
||||
|
||||
let asserted = false;
|
||||
let json = Infinity;
|
||||
setLoggingJson(true);
|
||||
const child = spawn(cli, [`--config`, testConfigFile]);
|
||||
|
||||
child.on('error', err => {
|
||||
done(new Error(`error in child process while attempting to reload config. ${err.stack || err.message || err}`));
|
||||
});
|
||||
|
||||
child.on('exit', code => {
|
||||
expect([null, 0]).to.contain(code);
|
||||
expect(asserted).to.eql(true);
|
||||
done();
|
||||
});
|
||||
|
||||
child.stdout
|
||||
.pipe(es.split())
|
||||
.pipe(es.mapSync(function (line) {
|
||||
if (!line) {
|
||||
return line; // ignore empty lines
|
||||
}
|
||||
if (json--) {
|
||||
expect(parseJsonLogLine).withArgs(line).to.not.throwError();
|
||||
} else {
|
||||
expectPlainTextLogLine(line);
|
||||
}
|
||||
}));
|
||||
|
||||
function parseJsonLogLine(line) {
|
||||
try {
|
||||
const data = JSON.parse(line);
|
||||
const listening = data.tags.indexOf(`listening`) !== -1;
|
||||
if (listening) {
|
||||
switchToPlainTextLog();
|
||||
}
|
||||
} catch (err) {
|
||||
expect(`Error parsing log line as JSON\n ${err.stack || err.message || err}`).to.eql(true);
|
||||
}
|
||||
}
|
||||
|
||||
function switchToPlainTextLog() {
|
||||
json = 2; // ignore both "reloading" messages
|
||||
setLoggingJson(false);
|
||||
child.kill(`SIGHUP`); // reload logging config
|
||||
}
|
||||
|
||||
function expectPlainTextLogLine(line) {
|
||||
// assert
|
||||
const tags = `[info][config]`;
|
||||
const status = `Reloaded logging configuration due to SIGHUP.`;
|
||||
const expected = `${tags} ${status}`;
|
||||
const actual = line.slice(-expected.length);
|
||||
expect(actual).to.eql(expected);
|
||||
|
||||
// cleanup
|
||||
asserted = true;
|
||||
setLoggingJson(true);
|
||||
child.kill();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`cli invalid config support exits with statusCode 64 and logs a single line when config is invalid 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"@timestamp": "## @timestamp ##",
|
||||
"message": "\\"unknown.key\\", \\"other.unknown.key\\", \\"other.third\\", \\"some.flat.key\\", and \\"some.array\\" settings were not applied. Check for spelling errors and ensure that expected plugins are installed.",
|
||||
"pid": "## PID ##",
|
||||
"tags": Array [
|
||||
"fatal",
|
||||
],
|
||||
"type": "log",
|
||||
},
|
||||
]
|
||||
`;
|
|
@ -0,0 +1,69 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Server logging configuration should be reloadable via SIGHUP process signaling 1`] = `
|
||||
Object {
|
||||
"@timestamp": "## @timestamp ##",
|
||||
"message": "Plugin initialization disabled.",
|
||||
"pid": "## PID ##",
|
||||
"tags": Array [
|
||||
"info",
|
||||
],
|
||||
"type": "log",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Server logging configuration should be reloadable via SIGHUP process signaling 2`] = `
|
||||
Object {
|
||||
"@timestamp": "## @timestamp ##",
|
||||
"message": "Server running at http://localhost:8274",
|
||||
"pid": "## PID ##",
|
||||
"tags": Array [
|
||||
"listening",
|
||||
"info",
|
||||
],
|
||||
"type": "log",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Server logging configuration should be reloadable via SIGHUP process signaling 3`] = `
|
||||
Object {
|
||||
"@timestamp": "## @timestamp ##",
|
||||
"message": "Reloading logging configuration due to SIGHUP.",
|
||||
"pid": "## PID ##",
|
||||
"tags": Array [
|
||||
"info",
|
||||
"config",
|
||||
],
|
||||
"type": "log",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Server logging configuration should be reloadable via SIGHUP process signaling 4`] = `
|
||||
Object {
|
||||
"@timestamp": "## @timestamp ##",
|
||||
"message": "New logging configuration:
|
||||
{
|
||||
\\"ops\\": {
|
||||
\\"interval\\": 5000
|
||||
},
|
||||
\\"logging\\": {
|
||||
\\"json\\": false,
|
||||
\\"silent\\": false,
|
||||
\\"quiet\\": false,
|
||||
\\"verbose\\": false,
|
||||
\\"events\\": {},
|
||||
\\"dest\\": \\"stdout\\",
|
||||
\\"filter\\": {},
|
||||
\\"useUTC\\": true
|
||||
}
|
||||
}",
|
||||
"pid": "## PID ##",
|
||||
"tags": Array [
|
||||
"info",
|
||||
"config",
|
||||
],
|
||||
"type": "log",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Server logging configuration should be reloadable via SIGHUP process signaling 5`] = `" log [## timestamp ##] [info][config] Reloaded logging configuration due to SIGHUP."`;
|
30
src/cli/serve/integration_tests/invalid_config.test.js
Normal file
30
src/cli/serve/integration_tests/invalid_config.test.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { spawnSync } from 'child_process';
|
||||
import { resolve } from 'path';
|
||||
|
||||
const ROOT_DIR = resolve(__dirname, '../../../../');
|
||||
const INVALID_CONFIG_PATH = resolve(__dirname, '__fixtures__/invalid_config.yml');
|
||||
|
||||
describe('cli invalid config support', function () {
|
||||
it('exits with statusCode 64 and logs a single line when config is invalid', function () {
|
||||
const { error, status, stdout } = spawnSync(process.execPath, [
|
||||
'src/cli',
|
||||
'--config', INVALID_CONFIG_PATH
|
||||
], {
|
||||
cwd: ROOT_DIR
|
||||
});
|
||||
|
||||
const logLines = stdout.toString('utf8')
|
||||
.split('\n')
|
||||
.filter(Boolean)
|
||||
.map(JSON.parse)
|
||||
.map(obj => ({
|
||||
...obj,
|
||||
pid: '## PID ##',
|
||||
'@timestamp': '## @timestamp ##'
|
||||
}));
|
||||
|
||||
expect(error).toBe(undefined);
|
||||
expect(status).toBe(64);
|
||||
expect(logLines).toMatchSnapshot();
|
||||
}, 20 * 1000);
|
||||
});
|
118
src/cli/serve/integration_tests/reload_logging_config.test.js
Normal file
118
src/cli/serve/integration_tests/reload_logging_config.test.js
Normal file
|
@ -0,0 +1,118 @@
|
|||
import { spawn } from 'child_process';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { relative, resolve } from 'path';
|
||||
import { safeDump } from 'js-yaml';
|
||||
import es from 'event-stream';
|
||||
import { readYamlConfig } from '../read_yaml_config';
|
||||
|
||||
const testConfigFile = follow('__fixtures__/reload_logging_config/kibana.test.yml');
|
||||
const kibanaPath = follow('../../../../scripts/kibana.js');
|
||||
|
||||
function follow(file) {
|
||||
return relative(process.cwd(), resolve(__dirname, file));
|
||||
}
|
||||
|
||||
function setLoggingJson(enabled) {
|
||||
const conf = readYamlConfig(testConfigFile);
|
||||
conf.logging = conf.logging || {};
|
||||
conf.logging.json = enabled;
|
||||
|
||||
const yaml = safeDump(conf);
|
||||
|
||||
writeFileSync(testConfigFile, yaml);
|
||||
}
|
||||
|
||||
const prepareJson = obj => ({
|
||||
...obj,
|
||||
pid: '## PID ##',
|
||||
'@timestamp': '## @timestamp ##'
|
||||
});
|
||||
|
||||
const prepareLogLine = str =>
|
||||
str.replace(
|
||||
/\[\d{2}:\d{2}:\d{2}.\d{3}\]/,
|
||||
'[## timestamp ##]'
|
||||
);
|
||||
|
||||
describe('Server logging configuration', function () {
|
||||
let child;
|
||||
let isJson;
|
||||
|
||||
beforeEach(() => {
|
||||
isJson = true;
|
||||
setLoggingJson(true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
isJson = true;
|
||||
setLoggingJson(true);
|
||||
|
||||
if (child !== undefined) {
|
||||
child.kill();
|
||||
child = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
if (isWindows) {
|
||||
it('SIGHUP is not a feature of Windows.', () => {
|
||||
// nothing to do for Windows
|
||||
});
|
||||
} else {
|
||||
it('should be reloadable via SIGHUP process signaling', function (done) {
|
||||
expect.assertions(6);
|
||||
|
||||
child = spawn('node', [kibanaPath, '--config', testConfigFile]);
|
||||
|
||||
child.on('error', err => {
|
||||
done(new Error(`error in child process while attempting to reload config. ${err.stack || err.message || err}`));
|
||||
});
|
||||
|
||||
child.on('exit', code => {
|
||||
expect([null, 0]).toContain(code);
|
||||
done();
|
||||
});
|
||||
|
||||
child.stdout
|
||||
.pipe(es.split())
|
||||
.pipe(es.mapSync(line => {
|
||||
if (!line) {
|
||||
// skip empty lines
|
||||
return;
|
||||
}
|
||||
|
||||
if (isJson) {
|
||||
const data = JSON.parse(line);
|
||||
expect(prepareJson(data)).toMatchSnapshot();
|
||||
|
||||
if (data.tags.includes('listening')) {
|
||||
switchToPlainTextLog();
|
||||
}
|
||||
} else if (line.startsWith('{')) {
|
||||
// We have told Kibana to stop logging json, but it hasn't completed
|
||||
// the switch yet, so we verify the messages that are logged while
|
||||
// switching over.
|
||||
|
||||
const data = JSON.parse(line);
|
||||
expect(prepareJson(data)).toMatchSnapshot();
|
||||
} else {
|
||||
// Kibana has successfully stopped logging json, so we verify the
|
||||
// log line and kill the server.
|
||||
|
||||
expect(prepareLogLine(line)).toMatchSnapshot();
|
||||
|
||||
child.kill();
|
||||
child = undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
function switchToPlainTextLog() {
|
||||
isJson = false;
|
||||
setLoggingJson(false);
|
||||
|
||||
// reload logging config
|
||||
child.kill('SIGHUP');
|
||||
}
|
||||
}, 60000);
|
||||
}
|
||||
});
|
|
@ -1,16 +1,15 @@
|
|||
import expect from 'expect.js';
|
||||
import { join, relative, resolve } from 'path';
|
||||
import { readYamlConfig } from '../read_yaml_config';
|
||||
import { readYamlConfig } from './read_yaml_config';
|
||||
|
||||
function fixture(name) {
|
||||
return resolve(__dirname, 'fixtures', name);
|
||||
return resolve(__dirname, '__fixtures__', name);
|
||||
}
|
||||
|
||||
describe('cli/serve/read_yaml_config', function () {
|
||||
it('reads a single config file', function () {
|
||||
const config = readYamlConfig(fixture('one.yml'));
|
||||
|
||||
expect(config).to.eql({
|
||||
expect(config).toEqual({
|
||||
foo: 1,
|
||||
bar: true,
|
||||
});
|
||||
|
@ -22,7 +21,7 @@ describe('cli/serve/read_yaml_config', function () {
|
|||
fixture('two.yml')
|
||||
]);
|
||||
|
||||
expect(config).to.eql({
|
||||
expect(config).toEqual({
|
||||
foo: 2,
|
||||
bar: true,
|
||||
baz: 'bonkers'
|
||||
|
@ -33,14 +32,14 @@ describe('cli/serve/read_yaml_config', function () {
|
|||
const oldCwd = process.cwd();
|
||||
const newCwd = join(oldCwd, '..');
|
||||
|
||||
before(function () {
|
||||
beforeAll(function () {
|
||||
process.chdir(newCwd);
|
||||
});
|
||||
|
||||
it('resolves relative files based on the cwd', function () {
|
||||
const relativePath = relative(newCwd, fixture('one.yml'));
|
||||
const config = readYamlConfig(relativePath);
|
||||
expect(config).to.eql({
|
||||
expect(config).toEqual({
|
||||
foo: 1,
|
||||
bar: true,
|
||||
});
|
||||
|
@ -49,10 +48,10 @@ describe('cli/serve/read_yaml_config', function () {
|
|||
it('fails to load relative paths, not found because of the cwd', function () {
|
||||
expect(function () {
|
||||
readYamlConfig(relative(oldCwd, fixture('one.yml')));
|
||||
}).to.throwException(/ENOENT/);
|
||||
}).toThrowError(/ENOENT/);
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
process.chdir(oldCwd);
|
||||
});
|
||||
});
|
|
@ -1,12 +1,11 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import mockFs from 'mock-fs';
|
||||
import { PassThrough } from 'stream';
|
||||
|
||||
import { Keystore } from '../../server/keystore';
|
||||
import { add } from '../add';
|
||||
import Logger from '../../cli_plugin/lib/logger';
|
||||
import * as prompt from '../../server/utils/prompt';
|
||||
import { Keystore } from '../server/keystore';
|
||||
import { add } from './add';
|
||||
import Logger from '../cli_plugin/lib/logger';
|
||||
import * as prompt from '../server/utils/prompt';
|
||||
|
||||
describe('Kibana keystore', () => {
|
||||
describe('add', () => {
|
||||
|
@ -66,7 +65,7 @@ describe('Kibana keystore', () => {
|
|||
|
||||
const { args } = prompt.confirm.getCall(0);
|
||||
|
||||
expect(args[0]).to.eql('Setting a2 already exists. Overwrite?');
|
||||
expect(args[0]).toEqual('Setting a2 already exists. Overwrite?');
|
||||
});
|
||||
|
||||
it('aborts if overwrite is denied', async () => {
|
||||
|
@ -101,7 +100,7 @@ describe('Kibana keystore', () => {
|
|||
|
||||
await add(keystore, 'foo');
|
||||
|
||||
expect(keystore.data.foo).to.eql('bar');
|
||||
expect(keystore.data.foo).toEqual('bar');
|
||||
});
|
||||
|
||||
it('persists updated keystore', async () => {
|
||||
|
@ -128,7 +127,7 @@ describe('Kibana keystore', () => {
|
|||
|
||||
await add(keystore, 'foo', { stdin: true, stdinStream: stdin });
|
||||
|
||||
expect(keystore.data.foo).to.eql('kibana');
|
||||
expect(keystore.data.foo).toEqual('kibana');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,11 +1,10 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import mockFs from 'mock-fs';
|
||||
|
||||
import { Keystore } from '../../server/keystore';
|
||||
import { create } from '../create';
|
||||
import Logger from '../../cli_plugin/lib/logger';
|
||||
import * as prompt from '../../server/utils/prompt';
|
||||
import { Keystore } from '../server/keystore';
|
||||
import { create } from './create';
|
||||
import Logger from '../cli_plugin/lib/logger';
|
||||
import * as prompt from '../server/utils/prompt';
|
||||
|
||||
describe('Kibana keystore', () => {
|
||||
describe('create', () => {
|
||||
|
@ -59,7 +58,7 @@ describe('Kibana keystore', () => {
|
|||
sinon.assert.calledOnce(prompt.confirm);
|
||||
const { args } = prompt.confirm.getCall(0);
|
||||
|
||||
expect(args[0]).to.eql('A Kibana keystore already exists. Overwrite?');
|
||||
expect(args[0]).toEqual('A Kibana keystore already exists. Overwrite?');
|
||||
});
|
||||
|
||||
it('aborts if overwrite is denied', async () => {
|
|
@ -1,9 +1,9 @@
|
|||
import sinon from 'sinon';
|
||||
import mockFs from 'mock-fs';
|
||||
|
||||
import { Keystore } from '../../server/keystore';
|
||||
import { list } from '../list';
|
||||
import Logger from '../../cli_plugin/lib/logger';
|
||||
import { Keystore } from '../server/keystore';
|
||||
import { list } from './list';
|
||||
import Logger from '../cli_plugin/lib/logger';
|
||||
|
||||
describe('Kibana keystore', () => {
|
||||
describe('list', () => {
|
|
@ -1,9 +1,8 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import mockFs from 'mock-fs';
|
||||
|
||||
import { Keystore } from '../../server/keystore';
|
||||
import { remove } from '../remove';
|
||||
import { Keystore } from '../server/keystore';
|
||||
import { remove } from './remove';
|
||||
|
||||
describe('Kibana keystore', () => {
|
||||
describe('remove', () => {
|
||||
|
@ -31,7 +30,7 @@ describe('Kibana keystore', () => {
|
|||
|
||||
remove(keystore, 'a2');
|
||||
|
||||
expect(keystore.data).to.eql({ 'a1.b2.c3': 'foo' });
|
||||
expect(keystore.data).toEqual({ 'a1.b2.c3': 'foo' });
|
||||
});
|
||||
|
||||
it('persists the keystore', () => {
|
Before Width: | Height: | Size: 204 KiB After Width: | Height: | Size: 204 KiB |
|
@ -1,93 +0,0 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import Progress from '../progress';
|
||||
import Logger from '../../lib/logger';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
describe('plugin installer', function () {
|
||||
|
||||
describe('progressReporter', function () {
|
||||
let logger;
|
||||
let progress;
|
||||
|
||||
beforeEach(function () {
|
||||
logger = new Logger({ silent: false, quiet: false });
|
||||
sinon.stub(logger, 'log');
|
||||
sinon.stub(logger, 'error');
|
||||
progress = new Progress(logger);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
logger.log.restore();
|
||||
logger.error.restore();
|
||||
});
|
||||
|
||||
describe('handleData', function () {
|
||||
|
||||
it('should show a max of 20 dots for full progress', function () {
|
||||
progress.init(1000);
|
||||
progress.progress(1000);
|
||||
progress.complete();
|
||||
|
||||
expect(logger.log.callCount).to.be(22);
|
||||
expect(logger.log.getCall(0).args[0]).to.match(/transfer/i);
|
||||
expect(logger.log.getCall(1).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(2).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(3).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(4).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(5).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(6).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(7).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(8).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(9).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(10).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(11).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(12).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(13).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(14).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(15).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(16).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(17).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(18).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(19).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(20).args[0]).to.be('.');
|
||||
expect(logger.log.getCall(21).args[0]).to.match(/complete/i);
|
||||
});
|
||||
|
||||
it('should show dot for each 5% of completion', function () {
|
||||
progress.init(1000);
|
||||
expect(logger.log.callCount).to.be(1);
|
||||
|
||||
progress.progress(50); //5%
|
||||
expect(logger.log.callCount).to.be(2);
|
||||
|
||||
progress.progress(100); //15%
|
||||
expect(logger.log.callCount).to.be(4);
|
||||
|
||||
progress.progress(200); //25%
|
||||
expect(logger.log.callCount).to.be(8);
|
||||
|
||||
progress.progress(590); //94%
|
||||
expect(logger.log.callCount).to.be(20);
|
||||
|
||||
progress.progress(60); //100%
|
||||
expect(logger.log.callCount).to.be(21);
|
||||
|
||||
//Any progress over 100% should be ignored.
|
||||
progress.progress(9999);
|
||||
expect(logger.log.callCount).to.be(21);
|
||||
|
||||
progress.complete();
|
||||
expect(logger.log.callCount).to.be(22);
|
||||
|
||||
expect(logger.log.getCall(0).args[0]).to.match(/transfer/i);
|
||||
expect(logger.log.getCall(21).args[0]).to.match(/complete/i);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -1,10 +1,9 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import fs from 'fs';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
import { cleanPrevious, cleanArtifacts } from '../cleanup';
|
||||
import Logger from '../../lib/logger';
|
||||
import { cleanPrevious, cleanArtifacts } from './cleanup';
|
||||
import Logger from '../lib/logger';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
|
@ -44,7 +43,7 @@ describe('kibana cli', function () {
|
|||
return cleanPrevious(settings, logger)
|
||||
.catch(errorStub)
|
||||
.then(function () {
|
||||
expect(errorStub.called).to.be(false);
|
||||
expect(errorStub.called).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -59,7 +58,7 @@ describe('kibana cli', function () {
|
|||
return cleanPrevious(settings, logger)
|
||||
.catch(errorStub)
|
||||
.then(function () {
|
||||
expect(errorStub.called).to.be(true);
|
||||
expect(errorStub.called).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -70,7 +69,7 @@ describe('kibana cli', function () {
|
|||
return cleanPrevious(settings, logger)
|
||||
.catch(errorStub)
|
||||
.then(function () {
|
||||
expect(logger.log.calledWith('Found previous install attempt. Deleting...')).to.be(true);
|
||||
expect(logger.log.calledWith('Found previous install attempt. Deleting...')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -84,7 +83,7 @@ describe('kibana cli', function () {
|
|||
return cleanPrevious(settings, logger)
|
||||
.catch(errorStub)
|
||||
.then(function () {
|
||||
expect(errorStub.called).to.be(true);
|
||||
expect(errorStub.called).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -95,7 +94,7 @@ describe('kibana cli', function () {
|
|||
return cleanPrevious(settings, logger)
|
||||
.catch(errorStub)
|
||||
.then(function () {
|
||||
expect(errorStub.called).to.be(false);
|
||||
expect(errorStub.called).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -111,7 +110,7 @@ describe('kibana cli', function () {
|
|||
sinon.stub(rimraf, 'sync');
|
||||
|
||||
cleanArtifacts(settings);
|
||||
expect(rimraf.sync.calledWith(settings.workingPath)).to.be(true);
|
||||
expect(rimraf.sync.calledWith(settings.workingPath)).toBe(true);
|
||||
});
|
||||
|
||||
it('should swallow any errors thrown by rimraf.sync', function () {
|
||||
|
@ -119,7 +118,7 @@ describe('kibana cli', function () {
|
|||
throw new Error('Something bad happened.');
|
||||
});
|
||||
|
||||
expect(cleanArtifacts).withArgs(settings).to.not.throwError();
|
||||
expect(() => cleanArtifacts(settings)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
|
@ -1,19 +1,18 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import nock from 'nock';
|
||||
import glob from 'glob-all';
|
||||
import rimraf from 'rimraf';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Logger from '../../lib/logger';
|
||||
import { UnsupportedProtocolError } from '../../lib/errors';
|
||||
import { download, _downloadSingle, _getFilePath, _checkFilePathDeprecation } from '../download';
|
||||
import Logger from '../lib/logger';
|
||||
import { UnsupportedProtocolError } from '../lib/errors';
|
||||
import { download, _downloadSingle, _getFilePath, _checkFilePathDeprecation } from './download';
|
||||
import { join } from 'path';
|
||||
import http from 'http';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
describe('plugin downloader', function () {
|
||||
const testWorkingPath = join(__dirname, '.test.data');
|
||||
const testWorkingPath = join(__dirname, '.test.data.download');
|
||||
const tempArchiveFilePath = join(testWorkingPath, 'archive.part');
|
||||
|
||||
const settings = {
|
||||
|
@ -26,7 +25,7 @@ describe('kibana cli', function () {
|
|||
|
||||
function expectWorkingPathEmpty() {
|
||||
const files = glob.sync('**/*', { cwd: testWorkingPath });
|
||||
expect(files).to.eql([]);
|
||||
expect(files).toEqual([]);
|
||||
}
|
||||
|
||||
function expectWorkingPathNotEmpty() {
|
||||
|
@ -35,7 +34,7 @@ describe('kibana cli', function () {
|
|||
'archive.part'
|
||||
];
|
||||
|
||||
expect(files.sort()).to.eql(expected.sort());
|
||||
expect(files.sort()).toEqual(expected.sort());
|
||||
}
|
||||
|
||||
function shouldReject() {
|
||||
|
@ -71,7 +70,7 @@ describe('kibana cli', function () {
|
|||
|
||||
return _downloadSingle(settings, logger, sourceUrl)
|
||||
.then(shouldReject, function (err) {
|
||||
expect(err.message).to.match(/ENOTFOUND/);
|
||||
expect(err.message).toMatch(/ENOTFOUND/);
|
||||
expectWorkingPathEmpty();
|
||||
});
|
||||
});
|
||||
|
@ -81,13 +80,13 @@ describe('kibana cli', function () {
|
|||
|
||||
return _downloadSingle(settings, logger, sourceUrl)
|
||||
.then(shouldReject, function (err) {
|
||||
expect(err).to.be.an(UnsupportedProtocolError);
|
||||
expect(err).toBeInstanceOf(UnsupportedProtocolError);
|
||||
expectWorkingPathEmpty();
|
||||
});
|
||||
});
|
||||
|
||||
it('should download a file from a valid http url', function () {
|
||||
const filePath = join(__dirname, 'replies/banana.jpg');
|
||||
const filePath = join(__dirname, '__fixtures__/replies/banana.jpg');
|
||||
|
||||
nock('http://example.com')
|
||||
.defaultReplyHeaders({
|
||||
|
@ -110,18 +109,18 @@ describe('kibana cli', function () {
|
|||
describe('local file downloader', function () {
|
||||
|
||||
it('should throw an ENOTFOUND error for an invalid local file', function () {
|
||||
const filePath = join(__dirname, 'replies/i-am-not-there.zip');
|
||||
const filePath = join(__dirname, '__fixtures__/replies/i-am-not-there.zip');
|
||||
const sourceUrl = 'file://' + filePath.replace(/\\/g, '/');
|
||||
|
||||
return _downloadSingle(settings, logger, sourceUrl)
|
||||
.then(shouldReject, function (err) {
|
||||
expect(err.message).to.match(/ENOTFOUND/);
|
||||
expect(err.message).toMatch(/ENOTFOUND/);
|
||||
expectWorkingPathEmpty();
|
||||
});
|
||||
});
|
||||
|
||||
it('should copy a valid local file', function () {
|
||||
const filePath = join(__dirname, 'replies/banana.jpg');
|
||||
const filePath = join(__dirname, '__fixtures__/replies/banana.jpg');
|
||||
const sourceUrl = 'file://' + filePath.replace(/\\/g, '/');
|
||||
|
||||
return _downloadSingle(settings, logger, sourceUrl)
|
||||
|
@ -136,14 +135,14 @@ describe('kibana cli', function () {
|
|||
|
||||
describe('_getFilePath', function () {
|
||||
it('should decode paths', function () {
|
||||
expect(_getFilePath('Test%20folder/file.zip')).to.equal('Test folder/file.zip');
|
||||
expect(_getFilePath('Test%20folder/file.zip')).toBe('Test folder/file.zip');
|
||||
});
|
||||
|
||||
it('should remove the leading slash from windows paths', function () {
|
||||
const platform = Object.getOwnPropertyDescriptor(process, 'platform');
|
||||
Object.defineProperty(process, 'platform', { value: 'win32' });
|
||||
|
||||
expect(_getFilePath('/C:/foo/bar')).to.equal('C:/foo/bar');
|
||||
expect(_getFilePath('/C:/foo/bar')).toBe('C:/foo/bar');
|
||||
|
||||
Object.defineProperty(process, 'platform', platform);
|
||||
});
|
||||
|
@ -159,15 +158,15 @@ describe('kibana cli', function () {
|
|||
};
|
||||
_checkFilePathDeprecation('file://foo/bar', logger);
|
||||
_checkFilePathDeprecation('file:///foo/bar', logger);
|
||||
expect(logger.log.callCount).to.be(1);
|
||||
expect(logger.log.calledWith('Install paths with file:// are deprecated, use file:/// instead')).to.be(true);
|
||||
expect(logger.log.callCount).toBe(1);
|
||||
expect(logger.log.calledWith('Install paths with file:// are deprecated, use file:/// instead')).toBe(true);
|
||||
Object.defineProperty(process, 'platform', platform);
|
||||
});
|
||||
});
|
||||
|
||||
describe('download', function () {
|
||||
it('should loop through bad urls until it finds a good one.', function () {
|
||||
const filePath = join(__dirname, 'replies/test_plugin.zip');
|
||||
const filePath = join(__dirname, '__fixtures__/replies/test_plugin.zip');
|
||||
settings.urls = [
|
||||
'http://example.com/badfile1.tar.gz',
|
||||
'http://example.com/badfile2.tar.gz',
|
||||
|
@ -188,16 +187,16 @@ describe('kibana cli', function () {
|
|||
|
||||
return download(settings, logger)
|
||||
.then(function () {
|
||||
expect(logger.log.getCall(0).args[0]).to.match(/badfile1.tar.gz/);
|
||||
expect(logger.log.getCall(1).args[0]).to.match(/badfile2.tar.gz/);
|
||||
expect(logger.log.getCall(2).args[0]).to.match(/I am a bad uri/);
|
||||
expect(logger.log.getCall(3).args[0]).to.match(/goodfile.tar.gz/);
|
||||
expect(logger.log.getCall(0).args[0]).toMatch(/badfile1.tar.gz/);
|
||||
expect(logger.log.getCall(1).args[0]).toMatch(/badfile2.tar.gz/);
|
||||
expect(logger.log.getCall(2).args[0]).toMatch(/I am a bad uri/);
|
||||
expect(logger.log.getCall(3).args[0]).toMatch(/goodfile.tar.gz/);
|
||||
expectWorkingPathNotEmpty();
|
||||
});
|
||||
});
|
||||
|
||||
it('should stop looping through urls when it finds a good one.', function () {
|
||||
const filePath = join(__dirname, 'replies/test_plugin.zip');
|
||||
const filePath = join(__dirname, '__fixtures__/replies/test_plugin.zip');
|
||||
settings.urls = [
|
||||
'http://example.com/badfile1.tar.gz',
|
||||
'http://example.com/badfile2.tar.gz',
|
||||
|
@ -221,7 +220,7 @@ describe('kibana cli', function () {
|
|||
return download(settings, logger)
|
||||
.then(function () {
|
||||
for (let i = 0; i < logger.log.callCount; i++) {
|
||||
expect(logger.log.getCall(i).args[0]).to.not.match(/badfile3.tar.gz/);
|
||||
expect(logger.log.getCall(i).args[0]).not.toMatch(/badfile3.tar.gz/);
|
||||
}
|
||||
expectWorkingPathNotEmpty();
|
||||
});
|
||||
|
@ -247,12 +246,12 @@ describe('kibana cli', function () {
|
|||
|
||||
return download(settings, logger)
|
||||
.then(shouldReject, function (err) {
|
||||
expect(err.message).to.match(/no valid url specified/i);
|
||||
expect(err.message).toMatch(/no valid url specified/i);
|
||||
expectWorkingPathEmpty();
|
||||
});
|
||||
});
|
||||
|
||||
after(function () {
|
||||
afterAll(function () {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
|
@ -288,21 +287,21 @@ describe('kibana cli', function () {
|
|||
});
|
||||
|
||||
function expectProxyHit() {
|
||||
expect(proxyHit).to.be(true);
|
||||
expect(proxyHit).toBe(true);
|
||||
}
|
||||
|
||||
function expectNoProxyHit() {
|
||||
expect(proxyHit).to.be(false);
|
||||
expect(proxyConnectHit).to.be(false);
|
||||
expect(proxyHit).toBe(false);
|
||||
expect(proxyConnectHit).toBe(false);
|
||||
}
|
||||
|
||||
function nockPluginForUrl(url) {
|
||||
nock(url)
|
||||
.get('/plugin.zip')
|
||||
.replyWithFile(200, join(__dirname, 'replies/test_plugin.zip'));
|
||||
.replyWithFile(200, join(__dirname, '__fixtures__/replies/test_plugin.zip'));
|
||||
}
|
||||
|
||||
before(function (done) {
|
||||
beforeAll(function (done) {
|
||||
proxy.listen(proxyPort, done);
|
||||
});
|
||||
|
||||
|
@ -336,7 +335,7 @@ describe('kibana cli', function () {
|
|||
expect().fail('Should not succeed a HTTPS proxy request.');
|
||||
}, () => {
|
||||
// Check if the proxy was actually hit before the failure.
|
||||
expect(proxyConnectHit).to.be(true);
|
||||
expect(proxyConnectHit).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -415,7 +414,7 @@ describe('kibana cli', function () {
|
|||
.then(expectNoProxyHit);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
afterAll(function (done) {
|
||||
proxy.close(done);
|
||||
});
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import index from '../index';
|
||||
import index from './index';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
|
@ -19,7 +18,7 @@ describe('kibana cli', function () {
|
|||
sinon.spy(program, 'command');
|
||||
|
||||
index(program);
|
||||
expect(program.command.calledWith('install <plugin/url>')).to.be(true);
|
||||
expect(program.command.calledWith('install <plugin/url>')).toBe(true);
|
||||
|
||||
program.command.restore();
|
||||
});
|
||||
|
@ -28,7 +27,7 @@ describe('kibana cli', function () {
|
|||
sinon.spy(program, 'description');
|
||||
|
||||
index(program);
|
||||
expect(program.description.calledWith('install a plugin')).to.be(true);
|
||||
expect(program.description.calledWith('install a plugin')).toBe(true);
|
||||
|
||||
program.description.restore();
|
||||
});
|
||||
|
@ -57,14 +56,14 @@ describe('kibana cli', function () {
|
|||
}
|
||||
}
|
||||
|
||||
expect(options).to.have.length(0);
|
||||
expect(options).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should call the action function', function () {
|
||||
sinon.spy(program, 'action');
|
||||
|
||||
index(program);
|
||||
expect(program.action.calledOnce).to.be(true);
|
||||
expect(program.action.calledOnce).toBe(true);
|
||||
|
||||
program.action.restore();
|
||||
});
|
|
@ -1,18 +1,17 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import mockFs from 'mock-fs';
|
||||
import Logger from '../../lib/logger';
|
||||
import Logger from '../lib/logger';
|
||||
import { join } from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
import mkdirp from 'mkdirp';
|
||||
import { existingInstall, assertVersion } from '../kibana';
|
||||
import { existingInstall, assertVersion } from './kibana';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
describe('plugin installer', function () {
|
||||
|
||||
describe('kibana', function () {
|
||||
const testWorkingPath = join(__dirname, '.test.data');
|
||||
const testWorkingPath = join(__dirname, '.test.data.kibana');
|
||||
const tempArchiveFilePath = join(testWorkingPath, 'archive.part');
|
||||
const pluginDir = join(__dirname, 'plugins');
|
||||
|
||||
|
@ -50,85 +49,38 @@ describe('kibana cli', function () {
|
|||
version: '5.0.0-SNAPSHOT',
|
||||
plugins: [ { name: 'foo', path: join(testWorkingPath, 'foo'), kibanaVersion: '5.0.0-SNAPSHOT' } ]
|
||||
};
|
||||
const errorStub = sinon.stub();
|
||||
|
||||
try {
|
||||
assertVersion(settings);
|
||||
}
|
||||
catch (err) {
|
||||
errorStub(err);
|
||||
}
|
||||
|
||||
expect(errorStub.called).to.be(false);
|
||||
expect(() => assertVersion(settings)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should throw an error if plugin is missing a kibana version.', function () {
|
||||
const errorStub = sinon.stub();
|
||||
|
||||
try {
|
||||
assertVersion(settings);
|
||||
}
|
||||
catch (err) {
|
||||
errorStub(err);
|
||||
}
|
||||
|
||||
expect(errorStub.firstCall.args[0]).to.match(/plugin package\.json is missing both a version property/i);
|
||||
expect(() => assertVersion(settings)).toThrow(
|
||||
/plugin package\.json is missing both a version property/i
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if plugin kibanaVersion does not match kibana version', function () {
|
||||
const errorStub = sinon.stub();
|
||||
settings.plugins[0].kibanaVersion = '1.2.3.4';
|
||||
|
||||
try {
|
||||
assertVersion(settings);
|
||||
}
|
||||
catch (err) {
|
||||
errorStub(err);
|
||||
}
|
||||
|
||||
expect(errorStub.firstCall.args[0]).to.match(/incorrect kibana version/i);
|
||||
expect(() => assertVersion(settings)).toThrow(/incorrect kibana version/i);
|
||||
});
|
||||
|
||||
it('should not throw an error if plugin kibanaVersion matches kibana version', function () {
|
||||
const errorStub = sinon.stub();
|
||||
settings.plugins[0].kibanaVersion = '1.0.0';
|
||||
|
||||
try {
|
||||
assertVersion(settings);
|
||||
}
|
||||
catch (err) {
|
||||
errorStub(err);
|
||||
}
|
||||
|
||||
expect(errorStub.called).to.be(false);
|
||||
expect(() => assertVersion(settings)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should ignore version info after the dash in checks on valid version', function () {
|
||||
const errorStub = sinon.stub();
|
||||
settings.plugins[0].kibanaVersion = '1.0.0-foo-bar-version-1.2.3';
|
||||
|
||||
try {
|
||||
assertVersion(settings);
|
||||
}
|
||||
catch (err) {
|
||||
errorStub(err);
|
||||
}
|
||||
|
||||
expect(errorStub.called).to.be(false);
|
||||
expect(() => assertVersion(settings)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should ignore version info after the dash in checks on invalid version', function () {
|
||||
const errorStub = sinon.stub();
|
||||
settings.plugins[0].kibanaVersion = '2.0.0-foo-bar-version-1.2.3';
|
||||
|
||||
try {
|
||||
assertVersion(settings);
|
||||
}
|
||||
catch (err) {
|
||||
errorStub(err);
|
||||
}
|
||||
|
||||
expect(errorStub.firstCall.args[0]).to.match(/incorrect kibana version/i);
|
||||
expect(() => assertVersion(settings)).toThrow(/incorrect kibana version/i);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -151,15 +103,15 @@ describe('kibana cli', function () {
|
|||
mockFs({ [`${pluginDir}/foo`]: {} });
|
||||
|
||||
existingInstall(settings, logger);
|
||||
expect(logger.error.firstCall.args[0]).to.match(/already exists/);
|
||||
expect(process.exit.called).to.be(true);
|
||||
expect(logger.error.firstCall.args[0]).toMatch(/already exists/);
|
||||
expect(process.exit.called).toBe(true);
|
||||
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
it('should not throw an error if the plugin does not exist.', function () {
|
||||
existingInstall(settings, logger);
|
||||
expect(logger.error.called).to.be(false);
|
||||
expect(logger.error.called).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,11 +1,10 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import glob from 'glob-all';
|
||||
import rimraf from 'rimraf';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Logger from '../../lib/logger';
|
||||
import { extract, getPackData } from '../pack';
|
||||
import { _downloadSingle } from '../download';
|
||||
import Logger from '../lib/logger';
|
||||
import { extract, getPackData } from './pack';
|
||||
import { _downloadSingle } from './download';
|
||||
import { join } from 'path';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
@ -13,7 +12,7 @@ describe('kibana cli', function () {
|
|||
describe('pack', function () {
|
||||
|
||||
let testNum = 0;
|
||||
const workingPathRoot = join(__dirname, '.test.data');
|
||||
const workingPathRoot = join(__dirname, '.test.data.pack');
|
||||
let testWorkingPath;
|
||||
let tempArchiveFilePath;
|
||||
let testPluginPath;
|
||||
|
@ -50,7 +49,7 @@ describe('kibana cli', function () {
|
|||
});
|
||||
|
||||
function copyReplyFile(filename) {
|
||||
const filePath = join(__dirname, 'replies', filename);
|
||||
const filePath = join(__dirname, '__fixtures__', 'replies', filename);
|
||||
const sourceUrl = 'file://' + filePath.replace(/\\/g, '/');
|
||||
|
||||
return _downloadSingle(settings, logger, sourceUrl);
|
||||
|
@ -83,7 +82,7 @@ describe('kibana cli', function () {
|
|||
'public/app.js',
|
||||
'extra file only in zip.txt'
|
||||
];
|
||||
expect(files.sort()).to.eql(expected.sort());
|
||||
expect(files.sort()).toEqual(expected.sort());
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -97,10 +96,10 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(() => {
|
||||
expect(settings.plugins[0].name).to.be('test-plugin');
|
||||
expect(settings.plugins[0].archivePath).to.be('kibana/test-plugin');
|
||||
expect(settings.plugins[0].version).to.be('1.0.0');
|
||||
expect(settings.plugins[0].kibanaVersion).to.be('1.0.0');
|
||||
expect(settings.plugins[0].name).toBe('test-plugin');
|
||||
expect(settings.plugins[0].archivePath).toBe('kibana/test-plugin');
|
||||
expect(settings.plugins[0].version).toBe('1.0.0');
|
||||
expect(settings.plugins[0].kibanaVersion).toBe('1.0.0');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -111,7 +110,7 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(() => {
|
||||
expect(settings.plugins[0].kibanaVersion).to.be('5.0.1');
|
||||
expect(settings.plugins[0].kibanaVersion).toBe('5.0.1');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -122,7 +121,7 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(() => {
|
||||
expect(settings.plugins[0].kibanaVersion).to.be('1.0.0');
|
||||
expect(settings.plugins[0].kibanaVersion).toBe('1.0.0');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -132,29 +131,29 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(() => {
|
||||
expect(settings.plugins[0].name).to.be('funger-plugin');
|
||||
expect(settings.plugins[0].archivePath).to.be('kibana/funger-plugin');
|
||||
expect(settings.plugins[0].version).to.be('1.0.0');
|
||||
expect(settings.plugins[0].name).toBe('funger-plugin');
|
||||
expect(settings.plugins[0].archivePath).toBe('kibana/funger-plugin');
|
||||
expect(settings.plugins[0].version).toBe('1.0.0');
|
||||
|
||||
expect(settings.plugins[1].name).to.be('pdf');
|
||||
expect(settings.plugins[1].archivePath).to.be('kibana/pdf-linux');
|
||||
expect(settings.plugins[1].version).to.be('1.0.0');
|
||||
expect(settings.plugins[1].name).toBe('pdf');
|
||||
expect(settings.plugins[1].archivePath).toBe('kibana/pdf-linux');
|
||||
expect(settings.plugins[1].version).toBe('1.0.0');
|
||||
|
||||
expect(settings.plugins[2].name).to.be('pdf');
|
||||
expect(settings.plugins[2].archivePath).to.be('kibana/pdf-win32');
|
||||
expect(settings.plugins[2].version).to.be('1.0.0');
|
||||
expect(settings.plugins[2].name).toBe('pdf');
|
||||
expect(settings.plugins[2].archivePath).toBe('kibana/pdf-win32');
|
||||
expect(settings.plugins[2].version).toBe('1.0.0');
|
||||
|
||||
expect(settings.plugins[3].name).to.be('pdf');
|
||||
expect(settings.plugins[3].archivePath).to.be('kibana/pdf-win64');
|
||||
expect(settings.plugins[3].version).to.be('1.0.0');
|
||||
expect(settings.plugins[3].name).toBe('pdf');
|
||||
expect(settings.plugins[3].archivePath).toBe('kibana/pdf-win64');
|
||||
expect(settings.plugins[3].version).toBe('1.0.0');
|
||||
|
||||
expect(settings.plugins[4].name).to.be('pdf');
|
||||
expect(settings.plugins[4].archivePath).to.be('kibana/pdf');
|
||||
expect(settings.plugins[4].version).to.be('1.0.0');
|
||||
expect(settings.plugins[4].name).toBe('pdf');
|
||||
expect(settings.plugins[4].archivePath).toBe('kibana/pdf');
|
||||
expect(settings.plugins[4].version).toBe('1.0.0');
|
||||
|
||||
expect(settings.plugins[5].name).to.be('test-plugin');
|
||||
expect(settings.plugins[5].archivePath).to.be('kibana/test-plugin');
|
||||
expect(settings.plugins[5].version).to.be('1.0.0');
|
||||
expect(settings.plugins[5].name).toBe('test-plugin');
|
||||
expect(settings.plugins[5].archivePath).toBe('kibana/test-plugin');
|
||||
expect(settings.plugins[5].version).toBe('1.0.0');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -164,7 +163,7 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(shouldReject, (err) => {
|
||||
expect(err.message).to.match(/No kibana plugins found in archive/i);
|
||||
expect(err.message).toMatch(/No kibana plugins found in archive/i);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -174,7 +173,7 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(shouldReject, (err) => {
|
||||
expect(err.message).to.match(/error retrieving/i);
|
||||
expect(err.message).toMatch(/error retrieving/i);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -184,7 +183,7 @@ describe('kibana cli', function () {
|
|||
return getPackData(settings, logger);
|
||||
})
|
||||
.then(shouldReject, (err) => {
|
||||
expect(err.message).to.match(/invalid plugin name/i);
|
||||
expect(err.message).toMatch(/invalid plugin name/i);
|
||||
});
|
||||
});
|
||||
|
92
src/cli_plugin/install/progress.test.js
Normal file
92
src/cli_plugin/install/progress.test.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
import sinon from 'sinon';
|
||||
import Progress from './progress';
|
||||
import Logger from '../lib/logger';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
describe('plugin installer', function () {
|
||||
|
||||
describe('progressReporter', function () {
|
||||
let logger;
|
||||
let progress;
|
||||
|
||||
beforeEach(function () {
|
||||
logger = new Logger({ silent: false, quiet: false });
|
||||
sinon.stub(logger, 'log');
|
||||
sinon.stub(logger, 'error');
|
||||
progress = new Progress(logger);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
logger.log.restore();
|
||||
logger.error.restore();
|
||||
});
|
||||
|
||||
describe('handleData', function () {
|
||||
|
||||
it('should show a max of 20 dots for full progress', function () {
|
||||
progress.init(1000);
|
||||
progress.progress(1000);
|
||||
progress.complete();
|
||||
|
||||
expect(logger.log.callCount).toBe(22);
|
||||
expect(logger.log.getCall(0).args[0]).toMatch(/transfer/i);
|
||||
expect(logger.log.getCall(1).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(2).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(3).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(4).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(5).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(6).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(7).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(8).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(9).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(10).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(11).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(12).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(13).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(14).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(15).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(16).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(17).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(18).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(19).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(20).args[0]).toBe('.');
|
||||
expect(logger.log.getCall(21).args[0]).toMatch(/complete/i);
|
||||
});
|
||||
|
||||
it('should show dot for each 5% of completion', function () {
|
||||
progress.init(1000);
|
||||
expect(logger.log.callCount).toBe(1);
|
||||
|
||||
progress.progress(50); //5%
|
||||
expect(logger.log.callCount).toBe(2);
|
||||
|
||||
progress.progress(100); //15%
|
||||
expect(logger.log.callCount).toBe(4);
|
||||
|
||||
progress.progress(200); //25%
|
||||
expect(logger.log.callCount).toBe(8);
|
||||
|
||||
progress.progress(590); //94%
|
||||
expect(logger.log.callCount).toBe(20);
|
||||
|
||||
progress.progress(60); //100%
|
||||
expect(logger.log.callCount).toBe(21);
|
||||
|
||||
//Any progress over 100% should be ignored.
|
||||
progress.progress(9999);
|
||||
expect(logger.log.callCount).toBe(21);
|
||||
|
||||
progress.complete();
|
||||
expect(logger.log.callCount).toBe(22);
|
||||
|
||||
expect(logger.log.getCall(0).args[0]).toMatch(/transfer/i);
|
||||
expect(logger.log.getCall(21).args[0]).toMatch(/complete/i);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -1,8 +1,7 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import fs from 'fs';
|
||||
|
||||
import { renamePlugin } from '../rename';
|
||||
import { renamePlugin } from './rename';
|
||||
|
||||
describe('plugin folder rename', function () {
|
||||
let renameStub;
|
||||
|
@ -24,8 +23,8 @@ describe('plugin folder rename', function () {
|
|||
|
||||
return renamePlugin('/foo/bar', '/bar/foo')
|
||||
.catch(function (err) {
|
||||
expect(err.code).to.be('error');
|
||||
expect(renameStub.callCount).to.be(1);
|
||||
expect(err.code).toBe('error');
|
||||
expect(renameStub.callCount).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -36,7 +35,7 @@ describe('plugin folder rename', function () {
|
|||
|
||||
return renamePlugin('/foo/bar', '/bar/foo')
|
||||
.then(function () {
|
||||
expect(renameStub.callCount).to.be(1);
|
||||
expect(renameStub.callCount).toBe(1);
|
||||
})
|
||||
.catch(function () {
|
||||
throw new Error('We shouln\'t have any errors');
|
||||
|
@ -56,7 +55,6 @@ describe('plugin folder rename', function () {
|
|||
});
|
||||
|
||||
it('should retry on Windows EPERM errors for up to 3 seconds', function () {
|
||||
this.timeout(5000);
|
||||
renameStub = sinon.stub(fs, 'rename', function (from, to, cb) {
|
||||
cb({
|
||||
code: 'EPERM'
|
||||
|
@ -64,9 +62,9 @@ describe('plugin folder rename', function () {
|
|||
});
|
||||
return renamePlugin('/foo/bar', '/bar/foo')
|
||||
.catch(function (err) {
|
||||
expect(err.code).to.be('EPERM');
|
||||
expect(renameStub.callCount).to.be.greaterThan(1);
|
||||
expect(err.code).toBe('EPERM');
|
||||
expect(renameStub.callCount).toBeGreaterThan(1);
|
||||
});
|
||||
});
|
||||
}, 5000);
|
||||
});
|
||||
});
|
|
@ -1,7 +1,6 @@
|
|||
import expect from 'expect.js';
|
||||
import { fromRoot } from '../../../utils';
|
||||
import { fromRoot } from '../../utils';
|
||||
import { resolve } from 'path';
|
||||
import { parseMilliseconds, parse } from '../settings';
|
||||
import { parseMilliseconds, parse } from './settings';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
|
@ -15,50 +14,50 @@ describe('kibana cli', function () {
|
|||
const value = '';
|
||||
const result = parseMilliseconds(value);
|
||||
|
||||
expect(result).to.be(0);
|
||||
expect(result).toBe(0);
|
||||
});
|
||||
|
||||
it('should return 0 for a number with an invalid unit of measure', function () {
|
||||
const result = parseMilliseconds('1gigablasts');
|
||||
expect(result).to.be(0);
|
||||
expect(result).toBe(0);
|
||||
});
|
||||
|
||||
it('should assume a number with no unit of measure is specified as milliseconds', function () {
|
||||
const result = parseMilliseconds(1);
|
||||
expect(result).to.be(1);
|
||||
expect(result).toBe(1);
|
||||
|
||||
const result2 = parseMilliseconds('1');
|
||||
expect(result2).to.be(1);
|
||||
expect(result2).toBe(1);
|
||||
});
|
||||
|
||||
it('should interpret a number with "s" as the unit of measure as seconds', function () {
|
||||
const result = parseMilliseconds('5s');
|
||||
expect(result).to.be(5 * 1000);
|
||||
expect(result).toBe(5 * 1000);
|
||||
});
|
||||
|
||||
it('should interpret a number with "second" as the unit of measure as seconds', function () {
|
||||
const result = parseMilliseconds('5second');
|
||||
expect(result).to.be(5 * 1000);
|
||||
expect(result).toBe(5 * 1000);
|
||||
});
|
||||
|
||||
it('should interpret a number with "seconds" as the unit of measure as seconds', function () {
|
||||
const result = parseMilliseconds('5seconds');
|
||||
expect(result).to.be(5 * 1000);
|
||||
expect(result).toBe(5 * 1000);
|
||||
});
|
||||
|
||||
it('should interpret a number with "m" as the unit of measure as minutes', function () {
|
||||
const result = parseMilliseconds('9m');
|
||||
expect(result).to.be(9 * 1000 * 60);
|
||||
expect(result).toBe(9 * 1000 * 60);
|
||||
});
|
||||
|
||||
it('should interpret a number with "minute" as the unit of measure as minutes', function () {
|
||||
const result = parseMilliseconds('9minute');
|
||||
expect(result).to.be(9 * 1000 * 60);
|
||||
expect(result).toBe(9 * 1000 * 60);
|
||||
});
|
||||
|
||||
it('should interpret a number with "minutes" as the unit of measure as minutes', function () {
|
||||
const result = parseMilliseconds('9minutes');
|
||||
expect(result).to.be(9 * 1000 * 60);
|
||||
expect(result).toBe(9 * 1000 * 60);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -77,14 +76,14 @@ describe('kibana cli', function () {
|
|||
it('should default to 0 (milliseconds)', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.timeout).to.be(0);
|
||||
expect(settings.timeout).toBe(0);
|
||||
});
|
||||
|
||||
it('should set settings.timeout property', function () {
|
||||
options.timeout = 1234;
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.timeout).to.be(1234);
|
||||
expect(settings.timeout).toBe(1234);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -94,14 +93,14 @@ describe('kibana cli', function () {
|
|||
it('should default to false', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.quiet).to.be(false);
|
||||
expect(settings.quiet).toBe(false);
|
||||
});
|
||||
|
||||
it('should set settings.quiet property to true', function () {
|
||||
options.quiet = true;
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.quiet).to.be(true);
|
||||
expect(settings.quiet).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -111,14 +110,14 @@ describe('kibana cli', function () {
|
|||
it('should default to false', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.silent).to.be(false);
|
||||
expect(settings.silent).toBe(false);
|
||||
});
|
||||
|
||||
it('should set settings.silent property to true', function () {
|
||||
options.silent = true;
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.silent).to.be(true);
|
||||
expect(settings.silent).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -128,14 +127,14 @@ describe('kibana cli', function () {
|
|||
it('should default to ZLS', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.config).to.be('');
|
||||
expect(settings.config).toBe('');
|
||||
});
|
||||
|
||||
it('should set settings.config property', function () {
|
||||
options.config = 'foo bar baz';
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.config).to.be('foo bar baz');
|
||||
expect(settings.config).toBe('foo bar baz');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -145,14 +144,14 @@ describe('kibana cli', function () {
|
|||
it('should default to plugins', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.pluginDir).to.be(fromRoot('plugins'));
|
||||
expect(settings.pluginDir).toBe(fromRoot('plugins'));
|
||||
});
|
||||
|
||||
it('should set settings.config property', function () {
|
||||
options.pluginDir = 'foo bar baz';
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.pluginDir).to.be('foo bar baz');
|
||||
expect(settings.pluginDir).toBe('foo bar baz');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -162,7 +161,7 @@ describe('kibana cli', function () {
|
|||
it('should set settings.plugin property', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.plugin).to.be(command);
|
||||
expect(settings.plugin).toBe(command);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -177,7 +176,7 @@ describe('kibana cli', function () {
|
|||
`https://artifacts.elastic.co/downloads/kibana-plugins/${command}/${command}-1234.zip`
|
||||
];
|
||||
|
||||
expect(settings.urls).to.eql(expected);
|
||||
expect(settings.urls).toEqual(expected);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -189,7 +188,7 @@ describe('kibana cli', function () {
|
|||
const settings = parse(command, options, kbnPackage);
|
||||
const expected = resolve('foo/bar/baz', '.plugin.installing');
|
||||
|
||||
expect(settings.workingPath).to.be(expected);
|
||||
expect(settings.workingPath).toBe(expected);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -201,7 +200,7 @@ describe('kibana cli', function () {
|
|||
const settings = parse(command, options, kbnPackage);
|
||||
const expected = resolve('foo/bar/baz', '.plugin.installing', 'archive.part');
|
||||
|
||||
expect(settings.tempArchiveFile).to.be(expected);
|
||||
expect(settings.tempArchiveFile).toBe(expected);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -213,7 +212,7 @@ describe('kibana cli', function () {
|
|||
const settings = parse(command, options, kbnPackage);
|
||||
const expected = resolve('foo/bar/baz', '.plugin.installing', 'package.json');
|
||||
|
||||
expect(settings.tempPackageFile).to.be(expected);
|
||||
expect(settings.tempPackageFile).toBe(expected);
|
||||
});
|
||||
|
||||
});
|
|
@ -1,14 +1,13 @@
|
|||
import expect from 'expect.js';
|
||||
import rimraf from 'rimraf';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import glob from 'glob';
|
||||
import { analyzeArchive, extractArchive, _isDirectory } from '../zip';
|
||||
import { analyzeArchive, extractArchive, _isDirectory } from './zip';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
describe('zip', function () {
|
||||
const repliesPath = path.resolve(__dirname, './replies');
|
||||
const repliesPath = path.resolve(__dirname, '__fixtures__', 'replies');
|
||||
const archivePath = path.resolve(repliesPath, 'test_plugin.zip');
|
||||
|
||||
let tempPath;
|
||||
|
@ -27,11 +26,11 @@ describe('kibana cli', function () {
|
|||
const packages = await analyzeArchive(archivePath);
|
||||
const plugin = packages[0];
|
||||
|
||||
expect(packages).to.be.an(Array);
|
||||
expect(plugin.name).to.be('test-plugin');
|
||||
expect(plugin.archivePath).to.be('kibana/test-plugin');
|
||||
expect(plugin.archive).to.be(archivePath);
|
||||
expect(plugin.kibanaVersion).to.be('1.0.0');
|
||||
expect(packages).toBeInstanceOf(Array);
|
||||
expect(plugin.name).toBe('test-plugin');
|
||||
expect(plugin.archivePath).toBe('kibana/test-plugin');
|
||||
expect(plugin.archive).toBe(archivePath);
|
||||
expect(plugin.kibanaVersion).toBe('1.0.0');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -50,7 +49,7 @@ describe('kibana cli', function () {
|
|||
'public/app.js',
|
||||
'README.md'
|
||||
];
|
||||
expect(files.sort()).to.eql(expected.sort());
|
||||
expect(files.sort()).toEqual(expected.sort());
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -66,17 +65,17 @@ describe('kibana cli', function () {
|
|||
|
||||
describe('_isDirectory', () => {
|
||||
it('should check for a forward slash', () => {
|
||||
expect(_isDirectory('/foo/bar/')).to.be(true);
|
||||
expect(_isDirectory('/foo/bar/')).toBe(true);
|
||||
});
|
||||
|
||||
it('should check for a backslash', () => {
|
||||
expect(_isDirectory('\\foo\\bar\\')).to.be(true);
|
||||
expect(_isDirectory('\\foo\\bar\\')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for files', () => {
|
||||
expect(_isDirectory('foo.txt')).to.be(false);
|
||||
expect(_isDirectory('\\path\\to\\foo.txt')).to.be(false);
|
||||
expect(_isDirectory('/path/to/foo.txt')).to.be(false);
|
||||
expect(_isDirectory('foo.txt')).toBe(false);
|
||||
expect(_isDirectory('\\path\\to\\foo.txt')).toBe(false);
|
||||
expect(_isDirectory('/path/to/foo.txt')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import Logger from '../logger';
|
||||
import Logger from './logger';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
|
@ -12,7 +11,7 @@ describe('kibana cli', function () {
|
|||
describe('logger.log', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
sinon.spy(process.stdout, 'write');
|
||||
sinon.stub(process.stdout, 'write');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
@ -26,8 +25,8 @@ describe('kibana cli', function () {
|
|||
logger.log(message);
|
||||
|
||||
const callCount = process.stdout.write.callCount;
|
||||
expect(process.stdout.write.getCall(callCount - 2).args[0]).to.be(message);
|
||||
expect(process.stdout.write.getCall(callCount - 1).args[0]).to.be('\n');
|
||||
expect(process.stdout.write.getCall(callCount - 2).args[0]).toBe(message);
|
||||
expect(process.stdout.write.getCall(callCount - 1).args[0]).toBe('\n');
|
||||
});
|
||||
|
||||
it('should log messages to the console and append not append a new line', function () {
|
||||
|
@ -37,20 +36,20 @@ describe('kibana cli', function () {
|
|||
}
|
||||
logger.log('Done!');
|
||||
|
||||
expect(process.stdout.write.callCount).to.be(13);
|
||||
expect(process.stdout.write.getCall(0).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(1).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(2).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(3).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(4).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(5).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(6).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(7).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(8).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(9).args[0]).to.be('.');
|
||||
expect(process.stdout.write.getCall(10).args[0]).to.be('\n');
|
||||
expect(process.stdout.write.getCall(11).args[0]).to.be('Done!');
|
||||
expect(process.stdout.write.getCall(12).args[0]).to.be('\n');
|
||||
expect(process.stdout.write.callCount).toBe(13);
|
||||
expect(process.stdout.write.getCall(0).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(1).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(2).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(3).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(4).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(5).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(6).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(7).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(8).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(9).args[0]).toBe('.');
|
||||
expect(process.stdout.write.getCall(10).args[0]).toBe('\n');
|
||||
expect(process.stdout.write.getCall(11).args[0]).toBe('Done!');
|
||||
expect(process.stdout.write.getCall(12).args[0]).toBe('\n');
|
||||
});
|
||||
|
||||
it('should not log any messages when quiet is set', function () {
|
||||
|
@ -64,7 +63,7 @@ describe('kibana cli', function () {
|
|||
}
|
||||
logger.log('Done!');
|
||||
|
||||
expect(process.stdout.write.callCount).to.be(0);
|
||||
expect(process.stdout.write.callCount).toBe(0);
|
||||
});
|
||||
|
||||
it('should not log any messages when silent is set', function () {
|
||||
|
@ -78,7 +77,7 @@ describe('kibana cli', function () {
|
|||
}
|
||||
logger.log('Done!');
|
||||
|
||||
expect(process.stdout.write.callCount).to.be(0);
|
||||
expect(process.stdout.write.callCount).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -86,7 +85,7 @@ describe('kibana cli', function () {
|
|||
describe('logger.error', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
sinon.spy(process.stderr, 'write');
|
||||
sinon.stub(process.stderr, 'write');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
@ -98,7 +97,7 @@ describe('kibana cli', function () {
|
|||
const message = 'this is my error';
|
||||
|
||||
logger.error(message);
|
||||
expect(process.stderr.write.calledWith(message + '\n')).to.be(true);
|
||||
expect(process.stderr.write.calledWith(message + '\n')).toBe(true);
|
||||
});
|
||||
|
||||
it('should log error messages to the console when quiet is set', function () {
|
||||
|
@ -106,7 +105,7 @@ describe('kibana cli', function () {
|
|||
const message = 'this is my error';
|
||||
|
||||
logger.error(message);
|
||||
expect(process.stderr.write.calledWith(message + '\n')).to.be(true);
|
||||
expect(process.stderr.write.calledWith(message + '\n')).toBe(true);
|
||||
});
|
||||
|
||||
it('should not log any error messages when silent is set', function () {
|
||||
|
@ -114,7 +113,7 @@ describe('kibana cli', function () {
|
|||
const message = 'this is my error';
|
||||
|
||||
logger.error(message);
|
||||
expect(process.stderr.write.callCount).to.be(0);
|
||||
expect(process.stderr.write.callCount).toBe(0);
|
||||
});
|
||||
|
||||
});
|
|
@ -1,9 +1,8 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import rimraf from 'rimraf';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Logger from '../../lib/logger';
|
||||
import list from '../list';
|
||||
import Logger from '../lib/logger';
|
||||
import list from './list';
|
||||
import { join } from 'path';
|
||||
import { writeFileSync, appendFileSync } from 'fs';
|
||||
|
||||
|
@ -18,7 +17,7 @@ describe('kibana cli', function () {
|
|||
|
||||
describe('plugin lister', function () {
|
||||
|
||||
const pluginDir = join(__dirname, '.test.data');
|
||||
const pluginDir = join(__dirname, '.test.data.list');
|
||||
let logger;
|
||||
|
||||
const settings = {
|
||||
|
@ -46,9 +45,9 @@ describe('kibana cli', function () {
|
|||
|
||||
list(settings, logger);
|
||||
|
||||
expect(logger.log.calledWith('plugin1@5.0.0-alpha2')).to.be(true);
|
||||
expect(logger.log.calledWith('plugin2@3.2.1')).to.be(true);
|
||||
expect(logger.log.calledWith('plugin3@1.2.3')).to.be(true);
|
||||
expect(logger.log.calledWith('plugin1@5.0.0-alpha2')).toBe(true);
|
||||
expect(logger.log.calledWith('plugin2@3.2.1')).toBe(true);
|
||||
expect(logger.log.calledWith('plugin3@1.2.3')).toBe(true);
|
||||
});
|
||||
|
||||
it('ignore folders that start with a period', function () {
|
||||
|
@ -60,8 +59,8 @@ describe('kibana cli', function () {
|
|||
|
||||
list(settings, logger);
|
||||
|
||||
expect(logger.log.calledWith('.foo@1.0.0')).to.be(false);
|
||||
expect(logger.log.calledWith('.bar@1.0.0')).to.be(false);
|
||||
expect(logger.log.calledWith('.foo@1.0.0')).toBe(false);
|
||||
expect(logger.log.calledWith('.bar@1.0.0')).toBe(false);
|
||||
});
|
||||
|
||||
it('list should only list folders', function () {
|
||||
|
@ -72,9 +71,9 @@ describe('kibana cli', function () {
|
|||
|
||||
list(settings, logger);
|
||||
|
||||
expect(logger.log.calledWith('plugin1@1.0.0')).to.be(true);
|
||||
expect(logger.log.calledWith('plugin2@1.0.0')).to.be(true);
|
||||
expect(logger.log.calledWith('plugin3@1.0.0')).to.be(true);
|
||||
expect(logger.log.calledWith('plugin1@1.0.0')).toBe(true);
|
||||
expect(logger.log.calledWith('plugin2@1.0.0')).toBe(true);
|
||||
expect(logger.log.calledWith('plugin3@1.0.0')).toBe(true);
|
||||
});
|
||||
|
||||
it('list should throw an exception if a plugin does not have a package.json', function () {
|
||||
|
@ -83,7 +82,7 @@ describe('kibana cli', function () {
|
|||
|
||||
expect(function () {
|
||||
list(settings, logger);
|
||||
}).to.throwError('Unable to read package.json file for plugin empty-plugin');
|
||||
}).toThrowError('Unable to read package.json file for plugin empty-plugin');
|
||||
});
|
||||
|
||||
it('list should throw an exception if a plugin have an empty package.json', function () {
|
||||
|
@ -94,7 +93,7 @@ describe('kibana cli', function () {
|
|||
|
||||
expect(function () {
|
||||
list(settings, logger);
|
||||
}).to.throwError('Unable to read package.json file for plugin invalid-plugin');
|
||||
}).toThrowError('Unable to read package.json file for plugin invalid-plugin');
|
||||
});
|
||||
|
||||
});
|
|
@ -1,6 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import { fromRoot } from '../../../utils';
|
||||
import { parse } from '../settings';
|
||||
import { fromRoot } from '../../utils';
|
||||
import { parse } from './settings';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
|
@ -21,14 +20,14 @@ describe('kibana cli', function () {
|
|||
it('should default to plugins', function () {
|
||||
const settings = parse(command, options);
|
||||
|
||||
expect(settings.pluginDir).to.be(fromRoot('plugins'));
|
||||
expect(settings.pluginDir).toBe(fromRoot('plugins'));
|
||||
});
|
||||
|
||||
it('should set settings.config property', function () {
|
||||
command.pluginDir = 'foo bar baz';
|
||||
const settings = parse(command, options);
|
||||
|
||||
expect(settings.pluginDir).to.be('foo bar baz');
|
||||
expect(settings.pluginDir).toBe('foo bar baz');
|
||||
});
|
||||
|
||||
});
|
|
@ -1,10 +1,9 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'sinon';
|
||||
import glob from 'glob-all';
|
||||
import rimraf from 'rimraf';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Logger from '../../lib/logger';
|
||||
import remove from '../remove';
|
||||
import Logger from '../lib/logger';
|
||||
import remove from './remove';
|
||||
import { join } from 'path';
|
||||
import { writeFileSync } from 'fs';
|
||||
|
||||
|
@ -12,7 +11,7 @@ describe('kibana cli', function () {
|
|||
|
||||
describe('plugin remover', function () {
|
||||
|
||||
const pluginDir = join(__dirname, '.test.data');
|
||||
const pluginDir = join(__dirname, '.test.data.remove');
|
||||
let processExitStub;
|
||||
let logger;
|
||||
|
||||
|
@ -39,16 +38,16 @@ describe('kibana cli', function () {
|
|||
settings.plugin = 'foo';
|
||||
|
||||
remove(settings, logger);
|
||||
expect(logger.error.firstCall.args[0]).to.match(/not installed/);
|
||||
expect(process.exit.called).to.be(true);
|
||||
expect(logger.error.firstCall.args[0]).toMatch(/not installed/);
|
||||
expect(process.exit.called).toBe(true);
|
||||
});
|
||||
|
||||
it('throw an error if the specified plugin is not a folder.', function () {
|
||||
writeFileSync(join(pluginDir, 'foo'), 'This is a file, and not a folder.');
|
||||
|
||||
remove(settings, logger);
|
||||
expect(logger.error.firstCall.args[0]).to.match(/not a plugin/);
|
||||
expect(process.exit.called).to.be(true);
|
||||
expect(logger.error.firstCall.args[0]).toMatch(/not a plugin/);
|
||||
expect(process.exit.called).toBe(true);
|
||||
});
|
||||
|
||||
it('delete the specified folder.', function () {
|
||||
|
@ -60,7 +59,7 @@ describe('kibana cli', function () {
|
|||
|
||||
const files = glob.sync('**/*', { cwd: pluginDir });
|
||||
const expected = ['bar'];
|
||||
expect(files.sort()).to.eql(expected.sort());
|
||||
expect(files.sort()).toEqual(expected.sort());
|
||||
});
|
||||
|
||||
});
|
|
@ -1,6 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import { fromRoot } from '../../../utils';
|
||||
import { parse } from '../settings';
|
||||
import { fromRoot } from '../../utils';
|
||||
import { parse } from './settings';
|
||||
|
||||
describe('kibana cli', function () {
|
||||
|
||||
|
@ -22,14 +21,14 @@ describe('kibana cli', function () {
|
|||
it('should default to false', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.quiet).to.be(false);
|
||||
expect(settings.quiet).toBe(false);
|
||||
});
|
||||
|
||||
it('should set settings.quiet property to true', function () {
|
||||
options.quiet = true;
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.quiet).to.be(true);
|
||||
expect(settings.quiet).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -39,14 +38,14 @@ describe('kibana cli', function () {
|
|||
it('should default to false', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.silent).to.be(false);
|
||||
expect(settings.silent).toBe(false);
|
||||
});
|
||||
|
||||
it('should set settings.silent property to true', function () {
|
||||
options.silent = true;
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.silent).to.be(true);
|
||||
expect(settings.silent).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -56,14 +55,14 @@ describe('kibana cli', function () {
|
|||
it('should default to ZLS', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.config).to.be('');
|
||||
expect(settings.config).toBe('');
|
||||
});
|
||||
|
||||
it('should set settings.config property', function () {
|
||||
options.config = 'foo bar baz';
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.config).to.be('foo bar baz');
|
||||
expect(settings.config).toBe('foo bar baz');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -73,14 +72,14 @@ describe('kibana cli', function () {
|
|||
it('should default to plugins', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.pluginDir).to.be(fromRoot('plugins'));
|
||||
expect(settings.pluginDir).toBe(fromRoot('plugins'));
|
||||
});
|
||||
|
||||
it('should set settings.config property', function () {
|
||||
options.pluginDir = 'foo bar baz';
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.pluginDir).to.be('foo bar baz');
|
||||
expect(settings.pluginDir).toBe('foo bar baz');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -90,7 +89,7 @@ describe('kibana cli', function () {
|
|||
it('should set settings.plugin property', function () {
|
||||
const settings = parse(command, options, kbnPackage);
|
||||
|
||||
expect(settings.plugin).to.be(command);
|
||||
expect(settings.plugin).toBe(command);
|
||||
});
|
||||
|
||||
});
|
|
@ -4,6 +4,9 @@ export default {
|
|||
'<rootDir>/src/ui',
|
||||
'<rootDir>/src/core_plugins',
|
||||
'<rootDir>/src/server',
|
||||
'<rootDir>/src/cli',
|
||||
'<rootDir>/src/cli_keystore',
|
||||
'<rootDir>/src/cli_plugin',
|
||||
'<rootDir>/packages',
|
||||
],
|
||||
collectCoverageFrom: [
|
||||
|
@ -58,6 +61,7 @@ export default {
|
|||
},
|
||||
transformIgnorePatterns: [
|
||||
'[/\\\\]node_modules[/\\\\].+\\.js$',
|
||||
'packages/kbn-pm/dist/index.js'
|
||||
],
|
||||
snapshotSerializers: [
|
||||
'<rootDir>/node_modules/enzyme-to-json/serializer',
|
||||
|
|
Loading…
Reference in a new issue