Skip to content

Commit

Permalink
chore: Add unit test for tabular query
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielelpidio committed Sep 19, 2024
1 parent 44fca09 commit 5c16574
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions packages/js/test/unit/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,95 @@ const queryResult = {
...queryLegacyResult,
};

const tabularQueryResult = {
format: 'tabular',
status: {
elapsedTime: 482939,
minCursor: '0d3fzkox77jls-075072aeef001913-00008ab9',
maxCursor: '0d3fzkox77jls-075072aeef001913-00008aba',
blocksExamined: 1024,
rowsExamined: 67083328,
rowsMatched: 36570280,
numGroups: 0,
isPartial: false,
cacheStatus: 1,
minBlockTime: '2024-08-14T22:23:58Z',
maxBlockTime: '2024-08-21T10:22:03Z',
},
tables: [
{
name: '0',
sources: [
{
name: 'sample-http-logs',
},
],
fields: [
{
name: 'status_int',
type: 'integer',
},
{
name: '_time',
type: 'datetime',
},
{
name: '_sysTime',
type: 'datetime',
},
{
name: 'simplified_agent',
type: 'string',
},
],
order: [
{
field: '_time',
desc: false,
},
],
groups: [],
range: {
field: '_time',
start: '2024-08-14T22:26:24.091Z',
end: '2024-08-29T22:26:24.091Z',
},
columns: [
[301, 500],
['2024-08-14T22:26:25Z', '2024-08-14T22:26:25Z'],
['2024-08-14T22:26:26.691450448Z', '2024-08-14T22:26:26.691450448Z'],
['Mozilla/5.0', 'Mozilla/5.0'],
],
},
],
datasetNames: ['sample-http-logs'],
fieldsMetaMap: {
'sample-http-logs': [
{
name: 'resp_body_size_bytes',
type: 'integer',
unit: 'decbytes',
hidden: false,
description: '',
},
{
name: 'req_duration_ms',
type: 'integer|float',
unit: 'ms',
hidden: false,
description: '',
},
{
name: 'resp_header_size_bytes',
type: 'integer',
unit: 'decbytes',
hidden: false,
description: '',
},
],
},
};

const clientURL = 'http://axiom-js-retries.dev.local';

describe('Axiom', () => {
Expand Down Expand Up @@ -267,6 +356,26 @@ describe('Axiom', () => {
expect(response).not.toEqual('undefined');
expect(response.matches).toHaveLength(2);
});

it('Tabular Query', async () => {
mockFetchResponse(tabularQueryResult);
// works without options
let response = await axiom.query("['sample-http-logs'] | where status_int != 200", { format: 'tabular' });
expect(response).not.toEqual('undefined');
expect(response.tables).toHaveLength(1);

// works with options
const options = {
streamingDuration: '1m',
noCache: true,
format: 'tabular' as const,
};

mockFetchResponse(tabularQueryResult);
response = await axiom.query("['sample-http-logs'] | where status_int != 200", options);
expect(response).not.toEqual('undefined');
expect(response.tables).toHaveLength(1);
});
});

describe('Tokens', () => {
Expand Down

0 comments on commit 5c16574

Please sign in to comment.