mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
force GET for metadataRequests, w/ test
This commit is contained in:
parent
006286ac05
commit
707700ac7d
@ -84,7 +84,7 @@ export class PrometheusDatasource {
|
||||
|
||||
// Use this for tab completion features, wont publish response to other components
|
||||
metadataRequest(url) {
|
||||
return this._request(url, null, { silent: true });
|
||||
return this._request(url, null, { method: 'GET', silent: true });
|
||||
}
|
||||
|
||||
interpolateQueryExpr(value, variable, defaultFormatFn) {
|
||||
|
@ -14,6 +14,7 @@ describe('PrometheusDatasource', () => {
|
||||
};
|
||||
|
||||
ctx.backendSrvMock = {};
|
||||
|
||||
ctx.templateSrvMock = {
|
||||
replace: a => a,
|
||||
};
|
||||
@ -23,6 +24,25 @@ describe('PrometheusDatasource', () => {
|
||||
ctx.ds = new PrometheusDatasource(instanceSettings, q, ctx.backendSrvMock, ctx.templateSrvMock, ctx.timeSrvMock);
|
||||
});
|
||||
|
||||
describe('Datasource metadata requests', () => {
|
||||
it('should perform a GET request with the default config', () => {
|
||||
ctx.backendSrvMock.datasourceRequest = jest.fn();
|
||||
ctx.ds.metadataRequest('/foo');
|
||||
expect(ctx.backendSrvMock.datasourceRequest.mock.calls.length).toBe(1);
|
||||
expect(ctx.backendSrvMock.datasourceRequest.mock.calls[0][0].method).toBe('GET');
|
||||
});
|
||||
|
||||
it('should still perform a GET request with the DS HTTP method set to POST', () => {
|
||||
ctx.backendSrvMock.datasourceRequest = jest.fn();
|
||||
const postSettings = _.cloneDeep(instanceSettings);
|
||||
postSettings.jsonData.httpMethod = 'POST';
|
||||
const ds = new PrometheusDatasource(postSettings, q, ctx.backendSrvMock, ctx.templateSrvMock, ctx.timeSrvMock);
|
||||
ds.metadataRequest('/foo');
|
||||
expect(ctx.backendSrvMock.datasourceRequest.mock.calls.length).toBe(1);
|
||||
expect(ctx.backendSrvMock.datasourceRequest.mock.calls[0][0].method).toBe('GET');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When converting prometheus histogram to heatmap format', () => {
|
||||
beforeEach(() => {
|
||||
ctx.query = {
|
||||
|
Loading…
Reference in New Issue
Block a user