mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s: Fix GetDashboards (#99484)
This commit is contained in:
committed by
GitHub
parent
af640e2e50
commit
6a205af5fe
@@ -1431,14 +1431,32 @@ func TestGetDashboards(t *testing.T) {
|
||||
Slug: "dashboard-1",
|
||||
OrgID: 1,
|
||||
Title: "Dashboard 1",
|
||||
Data: simplejson.NewFromAny(map[string]any{"title": "Dashboard 1", "uid": "uid1"}),
|
||||
},
|
||||
{
|
||||
UID: "uid2",
|
||||
Slug: "dashboard-2",
|
||||
OrgID: 1,
|
||||
Title: "Dashboard 2",
|
||||
Data: simplejson.NewFromAny(map[string]any{"title": "Dashboard 2", "uid": "uid2"}),
|
||||
},
|
||||
}
|
||||
uid1Unstructured := &unstructured.Unstructured{Object: map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"name": "uid1",
|
||||
},
|
||||
"spec": map[string]any{
|
||||
"title": "Dashboard 1",
|
||||
},
|
||||
}}
|
||||
uid2Unstructured := &unstructured.Unstructured{Object: map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"name": "uid2",
|
||||
},
|
||||
"spec": map[string]any{
|
||||
"title": "Dashboard 2",
|
||||
},
|
||||
}}
|
||||
queryByIDs := &dashboards.GetDashboardsQuery{
|
||||
DashboardIDs: []int64{1, 2},
|
||||
OrgID: 1,
|
||||
@@ -1467,6 +1485,8 @@ func TestGetDashboards(t *testing.T) {
|
||||
|
||||
t.Run("Should use Kubernetes client if feature flags are enabled", func(t *testing.T) {
|
||||
ctx, k8sCliMock := setupK8sDashboardTests(service)
|
||||
k8sCliMock.On("Get", mock.Anything, "uid1", mock.Anything, mock.Anything).Return(uid1Unstructured, nil)
|
||||
k8sCliMock.On("Get", mock.Anything, "uid2", mock.Anything, mock.Anything).Return(uid2Unstructured, nil)
|
||||
k8sCliMock.On("Search", mock.Anything, mock.Anything, mock.Anything).Return(&resource.ResourceSearchResponse{
|
||||
Results: &resource.ResourceTable{
|
||||
Columns: []*resource.ResourceTableColumnDefinition{
|
||||
|
||||
Reference in New Issue
Block a user