[v11.0.x] Prometheus: Create jsonschema spec (#86197)
Prometheus: Create jsonschema spec (#85077)
(cherry picked from commit e5cf863973)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e00a5ec73e
commit
8d366eb67c
@@ -7,6 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
sdkapi "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/experimental/schemabuilder"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/promlib/intervalv2"
|
||||
@@ -782,3 +784,38 @@ func TestAlignTimeRange(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryTypeDefinitions(t *testing.T) {
|
||||
builder, err := schemabuilder.NewSchemaBuilder(
|
||||
schemabuilder.BuilderOptions{
|
||||
PluginID: []string{"prometheus"},
|
||||
ScanCode: []schemabuilder.CodePaths{{
|
||||
BasePackage: "github.com/grafana/grafana/pkg/promlib/models",
|
||||
CodePath: "./",
|
||||
}},
|
||||
Enums: []reflect.Type{
|
||||
reflect.TypeOf(models.PromQueryFormatTimeSeries), // pick an example value (not the root)
|
||||
reflect.TypeOf(models.QueryEditorModeBuilder),
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
err = builder.AddQueries(
|
||||
schemabuilder.QueryTypeInfo{
|
||||
Name: "default",
|
||||
GoType: reflect.TypeOf(&models.PrometheusQueryProperties{}),
|
||||
Examples: []sdkapi.QueryExample{
|
||||
{
|
||||
Name: "simple health check",
|
||||
SaveModel: sdkapi.AsUnstructured(
|
||||
models.PrometheusQueryProperties{
|
||||
Expr: "1+1",
|
||||
},
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
require.NoError(t, err)
|
||||
builder.UpdateQueryDefinition(t, "./")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user