Scuemata: Simplify grafana-cli cue validation tests (#33913)
* Simplify tests * Make PanelFieldConfig optional in missing panel scenario
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"io/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -12,17 +10,13 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed testdata/public/*/*.cue testdata/public/*/plugin.json
|
|
||||||
var base embed.FS
|
|
||||||
var pluginSchema, _ = fs.Sub(base, "testdata/public")
|
|
||||||
|
|
||||||
func TestValidateScuemataBasics(t *testing.T) {
|
func TestValidateScuemataBasics(t *testing.T) {
|
||||||
t.Run("Testing scuemata validity with valid cue schemas", func(t *testing.T) {
|
t.Run("Testing scuemata validity with valid cue schemas", func(t *testing.T) {
|
||||||
tempDir := os.DirFS(filepath.Join("testdata", "valid_scuemata"))
|
tempDir := os.DirFS(filepath.Join("testdata", "valid_scuemata"))
|
||||||
|
|
||||||
var baseLoadPaths = load.BaseLoadPaths{
|
var baseLoadPaths = load.BaseLoadPaths{
|
||||||
BaseCueFS: tempDir,
|
BaseCueFS: tempDir,
|
||||||
DistPluginCueFS: pluginSchema,
|
DistPluginCueFS: load.GetDefaultLoadPaths().DistPluginCueFS,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := validate(baseLoadPaths, load.BaseDashboardFamily)
|
err := validate(baseLoadPaths, load.BaseDashboardFamily)
|
||||||
@@ -37,7 +31,7 @@ func TestValidateScuemataBasics(t *testing.T) {
|
|||||||
|
|
||||||
var baseLoadPaths = load.BaseLoadPaths{
|
var baseLoadPaths = load.BaseLoadPaths{
|
||||||
BaseCueFS: tempDir,
|
BaseCueFS: tempDir,
|
||||||
DistPluginCueFS: pluginSchema,
|
DistPluginCueFS: load.GetDefaultLoadPaths().DistPluginCueFS,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := validate(baseLoadPaths, load.BaseDashboardFamily)
|
err := validate(baseLoadPaths, load.BaseDashboardFamily)
|
||||||
@@ -49,7 +43,7 @@ func TestValidateScuemataBasics(t *testing.T) {
|
|||||||
|
|
||||||
var baseLoadPaths = load.BaseLoadPaths{
|
var baseLoadPaths = load.BaseLoadPaths{
|
||||||
BaseCueFS: tempDir,
|
BaseCueFS: tempDir,
|
||||||
DistPluginCueFS: pluginSchema,
|
DistPluginCueFS: load.GetDefaultLoadPaths().DistPluginCueFS,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := validate(baseLoadPaths, load.BaseDashboardFamily)
|
err := validate(baseLoadPaths, load.BaseDashboardFamily)
|
||||||
|
|||||||
Vendored
+1
@@ -9,6 +9,7 @@ package scuemata
|
|||||||
#PanelSchema: {
|
#PanelSchema: {
|
||||||
PanelOptions: {...}
|
PanelOptions: {...}
|
||||||
PanelFieldConfig: {...}
|
PanelFieldConfig: {...}
|
||||||
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
// A lineage of panel schema
|
// A lineage of panel schema
|
||||||
|
|||||||
Vendored
+2
-1
@@ -8,7 +8,8 @@ package scuemata
|
|||||||
// the larger Dashboard schema.
|
// the larger Dashboard schema.
|
||||||
#PanelSchema: {
|
#PanelSchema: {
|
||||||
PanelOptions: {...}
|
PanelOptions: {...}
|
||||||
PanelFieldConfig: {...}
|
PanelFieldConfig?: {...}
|
||||||
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
// A lineage of panel schema
|
// A lineage of panel schema
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package grafanaschema
|
|
||||||
|
|
||||||
Family: {
|
|
||||||
lineages: [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
PanelOptions: {
|
|
||||||
showStarred: bool | *true
|
|
||||||
showRecentlyViewed: bool | *false
|
|
||||||
showSearch: bool | *false
|
|
||||||
showHeadings: bool | *true
|
|
||||||
maxItems: int | *10
|
|
||||||
query: string | *""
|
|
||||||
folderId?: int
|
|
||||||
tags: [...string] | *[]
|
|
||||||
},
|
|
||||||
PanelFieldConfig: {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
migrations: []
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "panel",
|
|
||||||
"name": "Dashboard list",
|
|
||||||
"id": "dashlist",
|
|
||||||
"skipDataQuery": true,
|
|
||||||
"info": {
|
|
||||||
"description": "List of dynamic links to other dashboards",
|
|
||||||
"author": {
|
|
||||||
"name": "Grafana Labs",
|
|
||||||
"url": "https://grafana.com"
|
|
||||||
},
|
|
||||||
"logos": {
|
|
||||||
"small": "img/icn-dashlist-panel.svg",
|
|
||||||
"large": "img/icn-dashlist-panel.svg"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ Family: scuemata.#Family & {
|
|||||||
// TODO must isolate or remove identifiers local to a Grafana instance...?
|
// TODO must isolate or remove identifiers local to a Grafana instance...?
|
||||||
id?: number
|
id?: number
|
||||||
// Unique dashboard identifier that can be generated by anyone. string (8-40)
|
// Unique dashboard identifier that can be generated by anyone. string (8-40)
|
||||||
uid?: string
|
uid: string
|
||||||
// Title of dashboard.
|
// Title of dashboard.
|
||||||
title?: string
|
title?: string
|
||||||
// Description of dashboard.
|
// Description of dashboard.
|
||||||
|
|||||||
+5
-4
@@ -7,8 +7,9 @@ package scuemata
|
|||||||
// rather, they are composed into panel structures as they are defined within
|
// rather, they are composed into panel structures as they are defined within
|
||||||
// the larger Dashboard schema.
|
// the larger Dashboard schema.
|
||||||
#PanelSchema: {
|
#PanelSchema: {
|
||||||
PanelOptions: {...}
|
PanelOptions: {...}
|
||||||
PanelFieldConfig: {...}
|
PanelFieldConfig?: {...}
|
||||||
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
// A lineage of panel schema
|
// A lineage of panel schema
|
||||||
@@ -16,6 +17,6 @@ package scuemata
|
|||||||
|
|
||||||
// Panel plugin-specific Family
|
// Panel plugin-specific Family
|
||||||
#PanelFamily: {
|
#PanelFamily: {
|
||||||
lineages: [#PanelLineage, ...#PanelLineage]
|
lineages: [#PanelLineage, ...#PanelLineage]
|
||||||
migrations: [...#Migration]
|
migrations: [...#Migration]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user