|
|
|
@ -471,6 +471,34 @@ describe('VariableSupport', () => { |
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return None when there is no data', (done) => { |
|
|
|
|
const variableSupport = new VariableSupport( |
|
|
|
|
createMockDatasource({ |
|
|
|
|
azureLogAnalyticsDatasource: { |
|
|
|
|
defaultSubscriptionId: 'defaultSubscriptionId', |
|
|
|
|
}, |
|
|
|
|
getMetricNames: jest.fn().mockResolvedValueOnce([]), |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
const mockRequest = { |
|
|
|
|
targets: [ |
|
|
|
|
{ |
|
|
|
|
refId: 'A', |
|
|
|
|
queryType: AzureQueryType.GrafanaTemplateVariableFn, |
|
|
|
|
grafanaTemplateVariableFn: { |
|
|
|
|
kind: 'MetricNamesQuery', |
|
|
|
|
rawQuery: 'metricNames(resourceGroup, metricDefinition, resourceName, metricNamespace)', |
|
|
|
|
}, |
|
|
|
|
} as AzureMonitorQuery, |
|
|
|
|
], |
|
|
|
|
} as DataQueryRequest<AzureMonitorQuery>; |
|
|
|
|
const observables = variableSupport.query(mockRequest); |
|
|
|
|
observables.subscribe((result: DataQueryResponseData) => { |
|
|
|
|
expect(result.data.length).toBe(0); |
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('passes on the query to the main datasource for all non-grafana template variable fns', (done) => { |
|
|
|
|