Skip to content

Commit

Permalink
Fix broken TopN test (#72)
Browse files Browse the repository at this point in the history
We had previously assumed that mget calls would always happen. However,
if there was no data from the initial search calls, then mget would not
be called, thus, the assertion failed.

Since we are making calls that return no data, I changed the assertion.
I also checked if response was valid (expected status code, expected
data type in the payload).
  • Loading branch information
jbcrail authored and rockdaboot committed Jul 5, 2022
1 parent 69d4fb8 commit 3e4dada
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/plugins/profiling/server/routes/topn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe('TopN data from Elasticsearch', () => {
});

describe('when fetching Stack Traces', () => {
it('should search first then mget', async () => {
await topNElasticSearchQuery(
it('should search first then skip mget', async () => {
const response = await topNElasticSearchQuery(
client,
logger,
index,
Expand All @@ -47,8 +47,14 @@ describe('TopN data from Elasticsearch', () => {
'StackTraceID',
kibanaResponseFactory
);

// Calls to mget are skipped since data doesn't exist
expect(client.search).toHaveBeenCalledTimes(2);
expect(client.mget).toHaveBeenCalledTimes(2);
expect(client.mget).toHaveBeenCalledTimes(0);

expect(response.status).toEqual(200);
expect(response.payload).toHaveProperty('TopN');
expect(response.payload).toHaveProperty('Metadata');
});
});
});

0 comments on commit 3e4dada

Please sign in to comment.