Skip to content

Commit 258e5ef

Browse files
committed
Fixing tests for metric_threshold_executor
1 parent 58da924 commit 258e5ef

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

x-pack/plugins/infra/server/lib/alerting/metric_threshold/metric_threshold_executor.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ services.scopedClusterClient.asCurrentUser.search.mockImplementation((params?: a
515515
}
516516
if (metric === 'test.metric.2') {
517517
return elasticsearchClientMock.createSuccessTransportRequestPromise(
518-
mocks.alternateMetricResponse(from)
518+
mocks.alternateMetricResponse()
519519
);
520520
} else if (metric === 'test.metric.3') {
521521
return elasticsearchClientMock.createSuccessTransportRequestPromise(
@@ -524,9 +524,7 @@ services.scopedClusterClient.asCurrentUser.search.mockImplementation((params?: a
524524
: mocks.emptyMetricResponse
525525
);
526526
}
527-
return elasticsearchClientMock.createSuccessTransportRequestPromise(
528-
mocks.basicMetricResponse(from)
529-
);
527+
return elasticsearchClientMock.createSuccessTransportRequestPromise(mocks.basicMetricResponse());
530528
});
531529
services.savedObjectsClient.get.mockImplementation(async (type: string, sourceId: string) => {
532530
if (sourceId === 'alternate')

x-pack/plugins/infra/server/lib/alerting/metric_threshold/test_mocks.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,26 @@ const bucketsC = (from: number) => [
103103
},
104104
];
105105

106-
export const basicMetricResponse = (from: number) => ({
107-
aggregations: {
108-
aggregatedIntervals: {
109-
buckets: bucketsA(from),
106+
export const basicMetricResponse = () => ({
107+
hits: {
108+
total: {
109+
value: 1,
110110
},
111111
},
112+
aggregations: {
113+
aggregatedValue: { value: 1.0, values: [{ key: 95.0, value: 1.0 }] },
114+
},
112115
});
113116

114-
export const alternateMetricResponse = (from: number) => ({
115-
aggregations: {
116-
aggregatedIntervals: {
117-
buckets: bucketsB(from),
117+
export const alternateMetricResponse = () => ({
118+
hits: {
119+
total: {
120+
value: 1,
118121
},
119122
},
123+
aggregations: {
124+
aggregatedValue: { value: 3, values: [{ key: 99.0, value: 3 }] },
125+
},
120126
});
121127

122128
export const emptyMetricResponse = {

0 commit comments

Comments
 (0)