|
|
@ -161,6 +161,9 @@ describe('InfluxDataSource Frontend Mode', () => { |
|
|
|
const mockTemplateService = new TemplateSrv(); |
|
|
|
const mockTemplateService = new TemplateSrv(); |
|
|
|
mockTemplateService.getAdhocFilters = jest.fn((_: string) => adhocFilters); |
|
|
|
mockTemplateService.getAdhocFilters = jest.fn((_: string) => adhocFilters); |
|
|
|
let ds = getMockInfluxDS(getMockDSInstanceSettings(), mockTemplateService); |
|
|
|
let ds = getMockInfluxDS(getMockDSInstanceSettings(), mockTemplateService); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const fetchMock = jest.fn().mockReturnValue(fetchResult);
|
|
|
|
|
|
|
|
|
|
|
|
it('query should contain the ad-hoc variable', () => { |
|
|
|
it('query should contain the ad-hoc variable', () => { |
|
|
|
ds.query(mockInfluxQueryRequest()); |
|
|
|
ds.query(mockInfluxQueryRequest()); |
|
|
|
const expected = encodeURIComponent( |
|
|
|
const expected = encodeURIComponent( |
|
|
@ -168,6 +171,54 @@ describe('InfluxDataSource Frontend Mode', () => { |
|
|
|
); |
|
|
|
); |
|
|
|
expect(fetchMock.mock.calls[0][0].data).toBe(`q=${expected}`); |
|
|
|
expect(fetchMock.mock.calls[0][0].data).toBe(`q=${expected}`); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should make the fetch call for adhoc filter keys', () => { |
|
|
|
|
|
|
|
fetchMock.mockReturnValue( |
|
|
|
|
|
|
|
of({ |
|
|
|
|
|
|
|
results: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
statement_id: 0, |
|
|
|
|
|
|
|
series: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'cpu', |
|
|
|
|
|
|
|
columns: ['tagKey'], |
|
|
|
|
|
|
|
values: [['datacenter'], ['geohash'], ['source']], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
ds.getTagKeys(); |
|
|
|
|
|
|
|
expect(fetchMock).toHaveBeenCalled(); |
|
|
|
|
|
|
|
const fetchReq = fetchMock.mock.calls[0][0]; |
|
|
|
|
|
|
|
expect(fetchReq).not.toBeNull(); |
|
|
|
|
|
|
|
expect(fetchReq.data).toMatch(encodeURIComponent(`SHOW TAG KEYS`)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should make the fetch call for adhoc filter values', () => { |
|
|
|
|
|
|
|
fetchMock.mockReturnValue( |
|
|
|
|
|
|
|
of({ |
|
|
|
|
|
|
|
results: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
statement_id: 0, |
|
|
|
|
|
|
|
series: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'mykey', |
|
|
|
|
|
|
|
columns: ['key', 'value'], |
|
|
|
|
|
|
|
values: [['mykey', 'value']], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
ds.getTagValues({ key: 'mykey', filters: [] }); |
|
|
|
|
|
|
|
expect(fetchMock).toHaveBeenCalled(); |
|
|
|
|
|
|
|
const fetchReq = fetchMock.mock.calls[0][0]; |
|
|
|
|
|
|
|
expect(fetchReq).not.toBeNull(); |
|
|
|
|
|
|
|
expect(fetchReq.data).toMatch(encodeURIComponent(`SHOW TAG VALUES WITH KEY = "mykey"`)); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('datasource contract', () => { |
|
|
|
describe('datasource contract', () => { |
|
|
|