Update UT.

Signed-off-by: Rao Yunkun <yunkunrao@yunify.com>
This commit is contained in:
Rao Yunkun
2021-04-19 17:36:40 +08:00
parent 5904e2e9be
commit ab86f606a8
5 changed files with 129 additions and 165 deletions

View File

@@ -331,7 +331,7 @@ func TestParseRequestParams(t *testing.T) {
fakeInformerFactory.KubeSphereSharedInformerFactory()
handler := NewHandler(client, nil, nil, fakeInformerFactory, ksClient, nil)
handler := NewHandler(client, nil, nil, fakeInformerFactory, ksClient, nil, nil)
result, err := handler.makeQueryOptions(tt.params, tt.lvl)
if err != nil {
@@ -419,3 +419,20 @@ func TestExportMetrics(t *testing.T) {
})
}
}
func TestGetMetricPosMap(t *testing.T) {
metrics := []monitoring.Metric{
{
MetricName: "a",
},
{
MetricName: "b",
},
}
metricMap := getMetricPosMap(metrics)
if metricMap["a"] != 0 ||
metricMap["b"] != 1 {
t.Fatal("getMetricPosMap failed")
}
}