Skip to content

Commit

Permalink
update tests to remove checking sources from config
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Oct 31, 2023
1 parent 6dabf5d commit db33848
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions x-pack/plugins/infra/server/lib/sources/sources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('the InfraSources lib', () => {
describe('getSourceConfiguration method', () => {
test('returns a source configuration if it exists', async () => {
const sourcesLib = new InfraSources({
config: createMockStaticConfiguration({}),
config: createMockStaticConfiguration(),
metricsClient: createMockMetricsDataClient('METRIC_ALIAS'),
});

Expand Down Expand Up @@ -50,42 +50,9 @@ describe('the InfraSources lib', () => {
});
});

test('adds missing attributes from the static configuration to a source configuration', async () => {
const sourcesLib = new InfraSources({
config: createMockStaticConfiguration({
default: {
metricAlias: 'METRIC_ALIAS',
logIndices: { type: 'index_pattern', indexPatternId: 'LOG_ALIAS' },
},
}),
metricsClient: createMockMetricsDataClient('METRIC_ALIAS'),
});

const request: any = createRequestContext({
id: 'TEST_ID',
version: 'foo',
type: infraSourceConfigurationSavedObjectName,
updated_at: '2000-01-01T00:00:00.000Z',
attributes: {},
references: [],
});

expect(
await sourcesLib.getSourceConfiguration(request.core.savedObjects.client, 'TEST_ID')
).toMatchObject({
id: 'TEST_ID',
version: 'foo',
updatedAt: 946684800000,
configuration: {
metricAlias: 'METRIC_ALIAS',
logIndices: { type: 'index_pattern', indexPatternId: 'LOG_ALIAS' },
},
});
});

test('adds missing attributes from the default configuration to a source configuration', async () => {
const sourcesLib = new InfraSources({
config: createMockStaticConfiguration({}),
config: createMockStaticConfiguration(),
metricsClient: createMockMetricsDataClient(),
});

Expand Down Expand Up @@ -113,7 +80,7 @@ describe('the InfraSources lib', () => {
});
});

const createMockStaticConfiguration = (sources: any): InfraConfig => ({
const createMockStaticConfiguration = (): InfraConfig => ({
alerting: {
inventory_threshold: {
group_by_page_size: 10000,
Expand All @@ -135,7 +102,6 @@ const createMockStaticConfiguration = (sources: any): InfraConfig => ({
logThresholdAlertRuleEnabled: true,
alertsAndRulesDropdownEnabled: true,
},
sources,
enabled: true,
});

Expand Down

0 comments on commit db33848

Please sign in to comment.