Skip to content

Commit

Permalink
resource installer attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Dec 3, 2021
1 parent 4e3764f commit 84a6eac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Schema = PublicMethodsOf<ResourceInstaller>;
export type ResourceInstallerMock = jest.Mocked<Schema>;
const createResourceInstallerMock = () => {
return {
installCommonResources: jest.fn(() => Promise.resolve()),
installCommonResources: jest.fn(),
installIndexLevelResources: jest.fn(),
installAndUpdateNamespaceLevelResources: jest.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks';
import { AlertConsumers } from '@kbn/rule-data-utils/alerts_as_data_rbac';
import { Dataset } from './index_options';
import { RuleDataClient } from '../rule_data_client/rule_data_client';
import { ResourceInstaller } from './resource_installer';
import { resourceInstallerMock as mockResourceInstaller } from './resource_installer.mock';
import { createRuleDataClientMock as mockCreateRuleDataClient } from '../rule_data_client/rule_data_client.mock';
jest.mock('../rule_data_client/rule_data_client', () => ({
RuleDataClient: jest.fn().mockImplementation(() => mockCreateRuleDataClient()),
}));
jest.mock('./resource_installer', () => ({
ResourceInstaller: jest.fn().mockImplementation(() => mockResourceInstaller.create()),
}));

describe('ruleDataPluginService', () => {
beforeEach(() => {
Expand Down Expand Up @@ -71,6 +76,24 @@ describe('ruleDataPluginService', () => {
});
});

describe('initializeService', () => {
it('calls ResourceInstaller', async () => {
const mockClusterClient = elasticsearchServiceMock.createElasticsearchClient();
const getClusterClient = jest.fn(() => Promise.resolve(mockClusterClient));

new RuleDataService({
logger: loggerMock.create(),
getClusterClient,
kibanaVersion: '8.1.0',
isWriteEnabled: true,
disabledRegistrationContexts: ['observability.logs'],
isWriterCacheEnabled: true,
});

expect(ResourceInstaller).toHaveBeenCalled();
});
});

describe('initializeIndex', () => {
it('calls RuleDataClient', async () => {
const mockClusterClient = elasticsearchServiceMock.createElasticsearchClient();
Expand Down

0 comments on commit 84a6eac

Please sign in to comment.