Skip to content

Commit

Permalink
Use kbn/utils to get current kibana version in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Mar 11, 2021
1 parent c79a508 commit 063ac5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": "true",
"main": "target/packages/kbn-es-archiver/src/index.js",
"main": "target/index.js",
"kibana": {
"devOnly": true
},
Expand Down
22 changes: 19 additions & 3 deletions packages/kbn-es-archiver/src/lib/archives/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
import Stream, { PassThrough, Readable, Writable, Transform } from 'stream';
import { createGzip } from 'zlib';

import { createConcatStream, createListStream, createPromiseFromStreams } from '@kbn/utils';
import {
createConcatStream,
createListStream,
createPromiseFromStreams,
kibanaPackageJson,
} from '@kbn/utils';

import { createParseArchiveStreams } from './parse';
import { version as kibanaPackageVersion } from '../../../../../package.json';

describe('esArchiver createParseArchiveStreams', () => {
describe('{ gzip: false }', () => {
Expand Down Expand Up @@ -63,7 +67,7 @@ describe('esArchiver createParseArchiveStreams', () => {
]),
...createParseArchiveStreams({ gzip: false }),
]);
return expect(output).toEqual({ [kibanaPackageVersion]: 'enabled' });
return expect(output).toEqual({ [kibanaPackageJson.version]: 'enabled' });
});

it('provides each JSON object as soon as it is parsed', async () => {
Expand Down Expand Up @@ -150,6 +154,18 @@ describe('esArchiver createParseArchiveStreams', () => {

expect(output).toEqual([{ a: 1 }, { a: 2 }]);
});

it('replaces $KIBANA_PACKAGE_VERSION with the current kibana version', async () => {
const output = await createPromiseFromStreams([
createListStream([
Buffer.from('{'),
Buffer.from('"$KIBANA_PACKAGE_VERSION": "enabled"}'),
]),
createGzip(),
...createParseArchiveStreams({ gzip: true }),
]);
return expect(output).toEqual({ [kibanaPackageJson.version]: 'enabled' });
});
});

it('parses blank files', async () => {
Expand Down

0 comments on commit 063ac5d

Please sign in to comment.