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.
[RAC] Update alert documents in lifecycle rule type helper (elastic#1…
…01598) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
08f099b
commit 79cce41
Showing
8 changed files
with
501 additions
and
32 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
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
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/rule_registry/server/rule_data_client/create_rule_data_client_mock.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,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { Assign } from '@kbn/utility-types'; | ||
import type { RuleDataClient } from '.'; | ||
import { RuleDataReader, RuleDataWriter } from './types'; | ||
|
||
type MockInstances<T extends Record<string, any>> = { | ||
[K in keyof T]: T[K] extends (...args: infer TArgs) => infer TReturn | ||
? jest.MockInstance<TReturn, TArgs> | ||
: never; | ||
}; | ||
|
||
export function createRuleDataClientMock() { | ||
const bulk = jest.fn(); | ||
const search = jest.fn(); | ||
const getDynamicIndexPattern = jest.fn(); | ||
|
||
return ({ | ||
createOrUpdateWriteTarget: jest.fn(({ namespace }) => Promise.resolve()), | ||
getReader: jest.fn(() => ({ | ||
getDynamicIndexPattern, | ||
search, | ||
})), | ||
getWriter: jest.fn(() => ({ | ||
bulk, | ||
})), | ||
} as unknown) as Assign< | ||
RuleDataClient & Omit<MockInstances<RuleDataClient>, 'options' | 'getClusterClient'>, | ||
{ | ||
getWriter: ( | ||
...args: Parameters<RuleDataClient['getWriter']> | ||
) => MockInstances<RuleDataWriter>; | ||
getReader: ( | ||
...args: Parameters<RuleDataClient['getReader']> | ||
) => MockInstances<RuleDataReader>; | ||
} | ||
>; | ||
} |
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.