mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fix documentMigrator for snapshot releases (#89936)
This commit is contained in:
parent
7a45fc45e1
commit
69f4c9d541
2 changed files with 15 additions and 1 deletions
|
@ -14,6 +14,16 @@ import { loggingSystemMock } from '../../../logging/logging_system.mock';
|
|||
import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import { SavedObjectsType } from '../../types';
|
||||
import { errors as esErrors } from '@elastic/elasticsearch';
|
||||
import { DocumentMigrator } from '../core/document_migrator';
|
||||
jest.mock('../core/document_migrator', () => {
|
||||
return {
|
||||
// Create a mock for spying on the constructor
|
||||
DocumentMigrator: jest.fn().mockImplementation((...args) => {
|
||||
const { DocumentMigrator: RealDocMigrator } = jest.requireActual('../core/document_migrator');
|
||||
return new RealDocMigrator(args[0]);
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
const createRegistry = (types: Array<Partial<SavedObjectsType>>) => {
|
||||
const registry = new SavedObjectTypeRegistry();
|
||||
|
@ -31,12 +41,16 @@ const createRegistry = (types: Array<Partial<SavedObjectsType>>) => {
|
|||
};
|
||||
|
||||
describe('KibanaMigrator', () => {
|
||||
beforeEach(() => {
|
||||
(DocumentMigrator as jest.Mock).mockClear();
|
||||
});
|
||||
describe('constructor', () => {
|
||||
it('coerces the current Kibana version if it has a hyphen', () => {
|
||||
const options = mockOptions();
|
||||
options.kibanaVersion = '3.2.1-SNAPSHOT';
|
||||
const migrator = new KibanaMigrator(options);
|
||||
expect(migrator.kibanaVersion).toEqual('3.2.1');
|
||||
expect((DocumentMigrator as jest.Mock).mock.calls[0][0].kibanaVersion).toEqual('3.2.1');
|
||||
});
|
||||
});
|
||||
describe('getActiveMappings', () => {
|
||||
|
|
|
@ -97,7 +97,7 @@ export class KibanaMigrator {
|
|||
this.log = logger;
|
||||
this.kibanaVersion = kibanaVersion.split('-')[0]; // coerce a semver-like string (x.y.z-SNAPSHOT) or prerelease version (x.y.z-alpha) to a regular semver (x.y.z);
|
||||
this.documentMigrator = new DocumentMigrator({
|
||||
kibanaVersion,
|
||||
kibanaVersion: this.kibanaVersion,
|
||||
typeRegistry,
|
||||
log: this.log,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue