Skip to content

Commit

Permalink
handle feature toggles properly
Browse files Browse the repository at this point in the history
  • Loading branch information
iwysiu committed Sep 13, 2024
1 parent 374f36d commit 3a1a97d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/opensearchDatasource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1370,9 +1370,16 @@ describe('OpenSearchDatasource', function (this: any) {
});

describe('getOpenSearchVersion backend flow', () => {
it('should return OpenSearch version', async () => {
beforeEach(() => {
// @ts-ignore-next-line
config.featureToggles.openSearchBackendFlowEnabled = true;
});

afterEach(() => {
// @ts-ignore-next-line
config.featureToggles.openSearchBackendFlowEnabled = false;
});
it('should return OpenSearch version', async () => {
const mockResource = jest.fn().mockResolvedValue({
version: { distribution: 'opensearch', number: '2.6.0' },
});
Expand All @@ -1387,8 +1394,6 @@ describe('OpenSearchDatasource', function (this: any) {
});

it('should return ElasticSearch version', async () => {
// @ts-ignore-next-line
config.featureToggles.openSearchBackendFlowEnabled = true;
ctx.ds.getResource = jest.fn().mockResolvedValue({
version: { number: '7.6.0' },
});
Expand All @@ -1400,8 +1405,6 @@ describe('OpenSearchDatasource', function (this: any) {
});

it('should error for invalid version', async () => {
// @ts-ignore-next-line
config.featureToggles.openSearchBackendFlowEnabled = true;
ctx.ds.getResource = jest.fn().mockResolvedValue({
version: { number: '7.11.1' },
});
Expand All @@ -1411,8 +1414,6 @@ describe('OpenSearchDatasource', function (this: any) {
});

it('should return ElasticSearch for ElasticSearch 7.10.2 without tagline', async () => {
// @ts-ignore-next-line
config.featureToggles.openSearchBackendFlowEnabled = true;
ctx.ds.getResource = jest.fn().mockResolvedValue({
version: { number: '7.10.2' },
});
Expand All @@ -1423,8 +1424,6 @@ describe('OpenSearchDatasource', function (this: any) {
});

it('should return OpenSearch for ElasticSearch 7.10.2 with tagline', async () => {
// @ts-ignore-next-line
config.featureToggles.openSearchBackendFlowEnabled = true;
ctx.ds.getResource = jest.fn().mockResolvedValue({
version: { number: '7.10.2' },
tagline: 'The OpenSearch Project: https://opensearch.org/',
Expand Down

0 comments on commit 3a1a97d

Please sign in to comment.