Skip to content

Commit

Permalink
Adds test for dataSource filter
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Jul 23, 2024
1 parent 22734f9 commit 78a99c1
Showing 1 changed file with 132 additions and 1 deletion.
133 changes: 132 additions & 1 deletion public/utils/test/datasource-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
* permissions and limitations under the License.
*/

import { getClusterInfo, getDataSourceFromUrl, setDataSourceInUrl } from '../datasource-utils';
import {
getClusterInfo,
getDataSourceFromUrl,
setDataSourceInUrl,
isDataSourceCompatible,
} from '../datasource-utils';

describe('Tests datasource utils', () => {
it('Tests the GetClusterDescription helper function', () => {
Expand Down Expand Up @@ -78,4 +83,130 @@ describe('Tests datasource utils', () => {
});
expect(getDataSourceFromUrl()).toEqual({});
});

describe('isDataSourceCompatible', () => {
it('should return true for compatible data sources', () => {
expect(
isDataSourceCompatible({
attributes: {
installedPlugins: ['opensearch-security'],
dataSourceVersion: '2.9.0',
title: '',
endpoint: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(true);
expect(
isDataSourceCompatible({
attributes: {
installedPlugins: ['opensearch-security'],
dataSourceVersion: '2.11.0',
title: '',
endpoint: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(true);
expect(
isDataSourceCompatible({
attributes: {
installedPlugins: ['opensearch-security'],
dataSourceVersion: '2.13.0',
title: '',
endpoint: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(true);
});

it('should return false for un-compatible data sources', () => {
expect(
isDataSourceCompatible({
attributes: {
installedPlugins: [],
dataSourceVersion: '2.13.0',
title: '',
endpoint: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(false);
expect(
isDataSourceCompatible({
attributes: {
installedPlugins: ['opensearch-ml'],
dataSourceVersion: '2.13.0',
title: '',
endpoint: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(false);
expect(
isDataSourceCompatible({
attributes: {
title: '',
endpoint: '',
dataSourceVersion: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(false);
expect(
isDataSourceCompatible({
attributes: {
installedPlugins: ['opensearch-security'],
dataSourceVersion: '1.0.0-beta1',
title: '',
endpoint: '',
auth: {
type: '',
credentials: undefined,
},
},
id: '',
type: '',
references: [],
})
).toBe(false);
});
});
});

0 comments on commit 78a99c1

Please sign in to comment.