Skip to content

Commit

Permalink
EMT-451: some more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nnamdifrankie committed Jun 25, 2020
1 parent 866b3e2 commit b310f92
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,6 @@ const noUnenrolledEndpoint = () =>

describe('test find all unenrolled HostId', () => {
let mockScopedClient: jest.Mocked<IScopedClusterClient>;
const expectedAllUnenrolledHostQuery = {
index: metadataMirrorIndexPattern,
scroll: '10s',
body: {
size: 1000,
_source: ['host.id'],
query: {
bool: {
filter: {
term: {
'Endpoint.status': EndpointStatus.unenrolled,
},
},
},
},
},
};

it('can find all hits with scroll', async () => {
const firstHostId = '1fdca33f-799f-49f4-939c-ea4383c77671';
Expand Down Expand Up @@ -74,9 +57,23 @@ describe('test find all unenrolled HostId', () => {
.mockImplementationOnce(noUnenrolledEndpoint);
const hostIds = await findAllUnenrolledHostIds(mockScopedClient);

expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]).toEqual(
expectedAllUnenrolledHostQuery
);
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]).toEqual({
index: metadataMirrorIndexPattern,
scroll: '30s',
body: {
size: 1000,
_source: ['host.id'],
query: {
bool: {
filter: {
term: {
'Endpoint.status': EndpointStatus.unenrolled,
},
},
},
},
},
});
expect(hostIds).toEqual([
{ host: { id: firstEndpointHostId } },
{ host: { id: secondEndpointHostId } },
Expand All @@ -94,6 +91,9 @@ describe('test find unenrolled endpoint host id by hostId', () => {
Promise.resolve(createSearchResponse(firstEndpointHostId, 'initialScrollId'))
);
const endpointHostId = await findUnenrolledHostByHostId(mockScopedClient, firstEndpointHostId);
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]?.index).toEqual(
metadataMirrorIndexPattern
);
expect(mockScopedClient.callAsCurrentUser.mock.calls[0][1]?.body).toEqual({
size: 1,
_source: ['host.id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SearchResponse } from 'elasticsearch';
import { metadataMirrorIndexPattern } from '../../../../../common/endpoint/constants';
import { EndpointStatus } from '../../../../../common/endpoint/types';

const KEEPALIVE = '10s';
const KEEPALIVE = '30s';
const SIZE = 1000;

export interface HostId {
Expand Down

0 comments on commit b310f92

Please sign in to comment.