-
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.
EMT-146: add more documentation and test
- Loading branch information
1 parent
e990c47
commit 2bd6601
Showing
2 changed files
with
51 additions
and
0 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
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/ingest_manager/server/services/agents/status.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,43 @@ | ||
/* | ||
* 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 { savedObjectsClientMock } from '../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock'; | ||
import { getAgentStatusById } from './status'; | ||
import { AGENT_TYPE_PERMANENT } from '../../../common/constants'; | ||
import { AgentSOAttributes } from '../../../common/types/models'; | ||
import { SavedObject } from 'kibana/server'; | ||
|
||
describe('Agent status service', () => { | ||
it('should return inactive when agent is not active', async () => { | ||
const mockSavedObjectsClient = savedObjectsClientMock.create(); | ||
mockSavedObjectsClient.get = jest.fn().mockReturnValue({ | ||
id: 'id', | ||
type: AGENT_TYPE_PERMANENT, | ||
attributes: { | ||
active: false, | ||
local_metadata: '{}', | ||
user_provided_metadata: '{}', | ||
}, | ||
} as SavedObject<AgentSOAttributes>); | ||
const status = await getAgentStatusById(mockSavedObjectsClient, 'id'); | ||
expect(status).toEqual('inactive'); | ||
}); | ||
|
||
it('should return online when agent is active', async () => { | ||
const mockSavedObjectsClient = savedObjectsClientMock.create(); | ||
mockSavedObjectsClient.get = jest.fn().mockReturnValue({ | ||
id: 'id', | ||
type: AGENT_TYPE_PERMANENT, | ||
attributes: { | ||
active: true, | ||
local_metadata: '{}', | ||
user_provided_metadata: '{}', | ||
}, | ||
} as SavedObject<AgentSOAttributes>); | ||
const status = await getAgentStatusById(mockSavedObjectsClient, 'id'); | ||
expect(status).toEqual('online'); | ||
}); | ||
}); |