mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 15:52:23 +08:00

* Move to new repository * Rename it to dual writer * Rename the function * Rename the methods * Rename to exportResource * Clean up logic in migrate and add TODOs * Add TODOs * Use generic client for unprovisioned * ForEachResource * More consolidation * Refactor more around client * Consolidate constants * ForEachFolder * More use of constants * Add FIXME notes * Use more constant * Remove Dashboard * Pass tree to folder manager * Replicate tree * Reduce export complexity * More refactoring * Use the ForEach for loading users * Limit in-memory folders * Isolate the object * Improve the export function * Move resources to resources package * Move delete operation * Move more logic * More consolidation * More renaming * Fix more issues * Ensure path exists when created a resource * Simply append error * Fix receiver lint issue * Fix cyclomatic complexity * Fix linting * Remove folder path creation
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package provisioning
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
|
|
"github.com/grafana/grafana/pkg/registry/apis/provisioning/resources"
|
|
)
|
|
|
|
// FIXME: do this tests make sense in their current form?
|
|
func TestIntegrationProvisioning_Client(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test")
|
|
}
|
|
helper := runGrafana(t)
|
|
|
|
ctx := context.Background()
|
|
clientFactory := resources.NewClientFactory(&helper.Org1.Admin)
|
|
clients, err := clientFactory.Clients(ctx, "default")
|
|
require.NoError(t, err)
|
|
|
|
t.Run("dashboard client support", func(t *testing.T) {
|
|
_, _, err := clients.ForResource(schema.GroupVersionResource{
|
|
Group: "dashboard.grafana.app",
|
|
Resource: "dashboards",
|
|
Version: "v1alpha1",
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
// With empty version, we should get the preferred version (v1alpha1)
|
|
_, _, err = clients.ForResource(schema.GroupVersionResource{
|
|
Group: "dashboard.grafana.app",
|
|
Resource: "dashboards",
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
_, _, err = clients.ForKind(schema.GroupVersionKind{
|
|
Group: "dashboard.grafana.app",
|
|
Version: "v1alpha1",
|
|
Kind: "Dashboard",
|
|
})
|
|
require.NoError(t, err)
|
|
})
|
|
}
|