|
|
|
@ -2,12 +2,15 @@ package conversion |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"strings" |
|
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
|
|
|
|
"k8s.io/apimachinery/pkg/runtime" |
|
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" |
|
|
|
|
"github.com/grafana/grafana/pkg/apimachinery/utils" |
|
|
|
|
dashboardV0 "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1" |
|
|
|
|
dashboardV1 "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1" |
|
|
|
|
dashboardV2 "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1" |
|
|
|
@ -15,9 +18,9 @@ import ( |
|
|
|
|
|
|
|
|
|
func TestConversionMatrixExist(t *testing.T) { |
|
|
|
|
versions := []v1.Object{ |
|
|
|
|
&dashboardV0.Dashboard{}, |
|
|
|
|
&dashboardV1.Dashboard{}, |
|
|
|
|
&dashboardV2.Dashboard{}, |
|
|
|
|
&dashboardV0.Dashboard{Spec: v0alpha1.Unstructured{Object: map[string]any{"title": "dashboardV0"}}}, |
|
|
|
|
&dashboardV1.Dashboard{Spec: v0alpha1.Unstructured{Object: map[string]any{"title": "dashboardV1"}}}, |
|
|
|
|
&dashboardV2.Dashboard{Spec: dashboardV2.DashboardSpec{Title: "dashboardV2"}}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scheme := runtime.NewScheme() |
|
|
|
@ -34,6 +37,11 @@ func TestConversionMatrixExist(t *testing.T) { |
|
|
|
|
err = scheme.Convert(in, out, nil) |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Make sure we get the right title for each value
|
|
|
|
|
meta, err := utils.MetaAccessor(in) |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
require.True(t, strings.HasPrefix(meta.FindTitle(""), "dashboard")) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|