forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swallows errors on ml lookups that we know might fail (elastic#25783) (…
…elastic#25844) * Swallows errors on ml lookups that we know can fail * Adjusts when we swallow ml lookup errors, fixes async test
- Loading branch information
1 parent
7cfb3e3
commit 5cd1f9b
Showing
3 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...lib/transactions/charts/get_avg_response_time_anomalies/__test__/get_anomaly_aggs.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
// @ts-ignore | ||
import { getAnomalyAggs } from '../get_anomaly_aggs'; | ||
|
||
test('getAnomalyAggs should swallow HTTP errors', () => { | ||
const httpError = new Error('anomaly lookup failed') as any; | ||
httpError.statusCode = 418; | ||
const failClient = jest.fn(() => Promise.reject(httpError)); | ||
|
||
return expect(getAnomalyAggs({ client: failClient })).resolves.toEqual(null); | ||
}); | ||
|
||
test('getAnomalyAggs should throw other errors', () => { | ||
const otherError = new Error('anomaly lookup ASPLODED') as any; | ||
const failClient = jest.fn(() => Promise.reject(otherError)); | ||
|
||
return expect( | ||
getAnomalyAggs({ | ||
client: failClient | ||
}) | ||
).rejects.toThrow(otherError); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters