-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Transforms - Updated: Add ability to delete dest index & index p…
…attern when deleting transform job (#68896)
- Loading branch information
Showing
25 changed files
with
1,166 additions
and
108 deletions.
There are no files selected for viewing
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,78 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { | ||
BoomResponse, | ||
extractErrorMessage, | ||
MLCustomHttpResponseOptions, | ||
MLResponseError, | ||
} from './errors'; | ||
import { ResponseError } from 'kibana/server'; | ||
|
||
describe('ML - error message utils', () => { | ||
describe('extractErrorMessage', () => { | ||
test('returns just the error message', () => { | ||
const testMsg = 'Saved object [index-pattern/blahblahblah] not found'; | ||
|
||
const bodyWithNestedErrorMsg: MLCustomHttpResponseOptions<MLResponseError> = { | ||
body: { | ||
message: { | ||
msg: testMsg, | ||
}, | ||
}, | ||
statusCode: 404, | ||
}; | ||
expect(extractErrorMessage(bodyWithNestedErrorMsg)).toBe(testMsg); | ||
|
||
const bodyWithStringMsg: MLCustomHttpResponseOptions<MLResponseError> = { | ||
body: { | ||
msg: testMsg, | ||
}, | ||
statusCode: 404, | ||
}; | ||
expect(extractErrorMessage(bodyWithStringMsg)).toBe(testMsg); | ||
|
||
const bodyWithStringMessage: MLCustomHttpResponseOptions<ResponseError> = { | ||
body: { | ||
message: testMsg, | ||
}, | ||
statusCode: 404, | ||
}; | ||
expect(extractErrorMessage(bodyWithStringMessage)).toBe(testMsg); | ||
|
||
const bodyWithString: MLCustomHttpResponseOptions<ResponseError> = { | ||
body: testMsg, | ||
statusCode: 404, | ||
}; | ||
expect(extractErrorMessage(bodyWithString)).toBe(testMsg); | ||
|
||
const bodyWithError: MLCustomHttpResponseOptions<ResponseError> = { | ||
body: new Error(testMsg), | ||
statusCode: 404, | ||
}; | ||
expect(extractErrorMessage(bodyWithError)).toBe(testMsg); | ||
|
||
const bodyWithBoomError: MLCustomHttpResponseOptions<BoomResponse> = { | ||
statusCode: 404, | ||
body: { | ||
data: [], | ||
isBoom: true, | ||
isServer: false, | ||
output: { | ||
statusCode: 404, | ||
payload: { | ||
statusCode: 404, | ||
error: testMsg, | ||
message: testMsg, | ||
}, | ||
headers: {}, | ||
}, | ||
}, | ||
}; | ||
expect(extractErrorMessage(bodyWithBoomError)).toBe(testMsg); | ||
}); | ||
}); | ||
}); |
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.