forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a migration function for datasource to add migrationVersion fi…
…eld (opensearch-project#6025) This PR is to add a migration function with version 2.4.0 for datasource to add a migrationVersion field. For more information, please refer to the RFC: opensearch-project#6022 Issues Resolved opensearch-project#6022 Signed-off-by: Yibo Wang <yibow@amazon.com>
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
src/plugins/data_source/server/saved_objects/data_source.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,29 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { migrateDataSource } from './data_source'; | ||
import { savedObjectsServiceMock } from '../../../../core/server/mocks'; | ||
|
||
const contextMock = savedObjectsServiceMock.createMigrationContext(); | ||
|
||
describe('migrateDataSource Function', () => { | ||
it('should return the input document unchanged', () => { | ||
const mockDoc = { | ||
id: 'test-id', | ||
type: 'test-type', | ||
attributes: { | ||
name: 'Test Name', | ||
description: 'Test Description', | ||
}, | ||
references: [], | ||
}; | ||
|
||
// Call the migrateDataSource function with the mock document | ||
const result = migrateDataSource(mockDoc, contextMock); | ||
|
||
// Expect the result to be deeply equal to the mock document | ||
expect(result).toEqual(mockDoc); | ||
}); | ||
}); |
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