mock more endpoints and fix tests
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
parent
7c205786e0
commit
de4698f63e
|
@ -321,6 +321,9 @@ class Cache {
|
|||
setLabelNamesAssociation(metricName: string, labelNames: string[]): void {
|
||||
const currentAssociation = this.getAssociations(metricName);
|
||||
labelNames.forEach((labelName) => {
|
||||
if (labelName === '__name__') {
|
||||
return;
|
||||
}
|
||||
if (!currentAssociation.has(labelName)) {
|
||||
currentAssociation.set(labelName, new Set<string>());
|
||||
}
|
||||
|
@ -396,7 +399,7 @@ export class CachedPrometheusClient implements PrometheusClient {
|
|||
}
|
||||
return this.client.labelNames(metricName).then((labelNames) => {
|
||||
this.cache.setLabelNames(labelNames, metricName);
|
||||
return labelNames;
|
||||
return this.cache.getLabelNames(metricName);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"status": "success",
|
||||
"data": [
|
||||
"demo"
|
||||
]
|
||||
}
|
|
@ -34,9 +34,12 @@ export function mockPrometheusServer(): void {
|
|||
.get('/api/v1/label/__name__/values')
|
||||
.query(true)
|
||||
.replyWithFile(200, __dirname + '/metric_name.json')
|
||||
.get('/api/v1/label/env/values')
|
||||
.query(true)
|
||||
.replyWithFile(200, __dirname + '/label_env_values.json')
|
||||
.get('/api/v1/metadata')
|
||||
.replyWithFile(200, __dirname + '/metadata.json')
|
||||
.get('/api/v1/labels')
|
||||
.post('/api/v1/labels')
|
||||
.query(true)
|
||||
.replyWithFile(200, __dirname + '/labels.json')
|
||||
.get('/api/v1/series')
|
||||
|
|
Loading…
Reference in New Issue