Skip to content

Commit

Permalink
[Multiple Datasource] Fix create data source wizard test
Browse files Browse the repository at this point in the history
Signed-off-by: Zilong Xia <zilongx@amazon.com>
  • Loading branch information
ZilongX committed Apr 4, 2024
1 parent cc34f97 commit 937926d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import React from 'react';
import {
fetchDataSourceVersion,
fetchDataSourceMetaData,
getMappedDataSources,
mockDataSourceAttributesWithAuth,
mockManagementPlugin,
Expand All @@ -28,8 +28,8 @@ describe('Datasource Management: Create Datasource Wizard', () => {
describe('case1: should load resources successfully', () => {
beforeEach(async () => {
spyOn(utils, 'getDataSources').and.returnValue(Promise.resolve(getMappedDataSources));
spyOn(utils, 'fetchDataSourceVersion').and.returnValue(
Promise.resolve(fetchDataSourceVersion)
spyOn(utils, 'fetchDataSourceMetaData').and.returnValue(
Promise.resolve(fetchDataSourceMetaData)
);
await act(async () => {
component = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
createSingleDataSource,
getDataSources,
testConnection,
fetchDataMetaData,
fetchDataSourceMetaData,
handleSetDefaultDatasource,
} from '../utils';
import { LoadingMask } from '../loading_mask';
Expand Down Expand Up @@ -76,7 +76,7 @@ export const CreateDataSourceWizard: React.FunctionComponent<CreateDataSourceWiz
setIsLoading(true);
try {
// Fetch data source metadata from added OS/ES domain/cluster
const metadata = await fetchDataMetaData(http, attributes);
const metadata = await fetchDataSourceMetaData(http, attributes);
attributes.dataSourceVersion = metadata.dataSourceVersion;
attributes.installedPlugins = metadata.installedPlugins;
await createSingleDataSource(savedObjects.client, attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export async function testConnection(
});
}

export async function fetchDataMetaData(
export async function fetchDataSourceMetaData(
http: HttpStart,
{ endpoint, auth: { type, credentials } }: DataSourceAttributes,
dataSourceID?: string
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data_source_management/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ export const getMappedDataSources = [
},
];

export const fetchDataSourceVersion = {
export const fetchDataSourceMetaData = {
dataSourceVersion: '2.11.0',
installedPlugins: ['opensearch-ml', 'opensearch-sql'],
};

export const mockDataSourceAttributesWithAuth = {
Expand Down

0 comments on commit 937926d

Please sign in to comment.