Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Mar 4, 2024
1 parent a29f248 commit c9056de
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ describe('IndexMigrator', () => {

testOpts.mappingProperties = { foo: { type: 'long' } as any };
const rawConfig = configMock.create();
rawConfig.get.mockReturnValue(true);
rawConfig.get.mockImplementation((path) => {
if (path === 'savedObjects.permission.enabled') {
return true;
} else {
return false;
}
});
testOpts.opensearchDashboardsRawConfig = rawConfig;

withIndex(client, { index: { statusCode: 404 }, alias: { statusCode: 404 } });
Expand Down Expand Up @@ -146,7 +152,13 @@ describe('IndexMigrator', () => {

testOpts.mappingProperties = { foo: { type: 'long' } as any };
const rawConfig = configMock.create();
rawConfig.get.mockReturnValue(true);
rawConfig.get.mockImplementation((path) => {
if (path === 'workspace.enabled') {
return true;
} else {
return false;
}
});
testOpts.opensearchDashboardsRawConfig = rawConfig;

withIndex(client, { index: { statusCode: 404 }, alias: { statusCode: 404 } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ const mockOptions = (isWorkspaceEnabled?: boolean, isPermissionControlEnabled?:
if (isWorkspaceEnabled || isPermissionControlEnabled) {
rawConfig.get.mockReturnValue(true);
}
rawConfig.get.mockImplementation((path) => {
if (path === 'savedObjects.permission.enabled') {
if (isPermissionControlEnabled) {
return true;
} else {
return false;
}
} else if (path === 'workspace.enabled') {
if (isWorkspaceEnabled) {
return true;
} else {
return false;
}
} else {
return false;
}
});
const options: MockedOptions = {
logger: loggingSystemMock.create().get(),
opensearchDashboardsVersion: '8.2.3',
Expand Down

0 comments on commit c9056de

Please sign in to comment.