-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Use skipFetchFields when creating the indexPatter…
…n in order to avoid errors if index doesn't exist (#113821) * Use skipFetchFields when creating the indexPatter in order to avoid errors when index doesnt exist * Address CR feedback Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
8236569
commit 6674293
Showing
2 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...ade_assistant/public/application/components/overview/fix_logs_step/external_links.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getDeprecationIndexPatternId } from './external_links'; | ||
|
||
import { DEPRECATION_LOGS_INDEX_PATTERN } from '../../../../../common/constants'; | ||
import { dataPluginMock, Start } from '../../../../../../../../src/plugins/data/public/mocks'; | ||
|
||
describe('External Links', () => { | ||
let dataService: Start; | ||
|
||
beforeEach(() => { | ||
dataService = dataPluginMock.createStartContract(); | ||
}); | ||
|
||
describe('getDeprecationIndexPatternId', () => { | ||
it('creates new index pattern if doesnt exist', async () => { | ||
dataService.dataViews.find = jest.fn().mockResolvedValue([]); | ||
dataService.dataViews.createAndSave = jest.fn().mockResolvedValue({ id: '123-456' }); | ||
|
||
const indexPatternId = await getDeprecationIndexPatternId(dataService); | ||
|
||
expect(indexPatternId).toBe('123-456'); | ||
// prettier-ignore | ||
expect(dataService.dataViews.createAndSave).toHaveBeenCalledWith({ | ||
title: DEPRECATION_LOGS_INDEX_PATTERN, | ||
allowNoIndex: true, | ||
}, false, true); | ||
}); | ||
|
||
it('uses existing index pattern if it already exists', async () => { | ||
dataService.dataViews.find = jest.fn().mockResolvedValue([ | ||
{ | ||
id: '123-456', | ||
title: DEPRECATION_LOGS_INDEX_PATTERN, | ||
}, | ||
]); | ||
|
||
const indexPatternId = await getDeprecationIndexPatternId(dataService); | ||
|
||
expect(indexPatternId).toBe('123-456'); | ||
expect(dataService.dataViews.find).toHaveBeenCalledWith(DEPRECATION_LOGS_INDEX_PATTERN); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters