The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/expr/ml/testing.go

48 lines
1.0 KiB

package ml
import (
"time"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/api/response"
)
type FakeCommand struct {
Method string
Path string
Payload []byte
Response *backend.QueryDataResponse
Error error
Recordings []struct {
From time.Time
To time.Time
Response response.Response
Error error
}
}
var _ Command = &FakeCommand{}
func (f *FakeCommand) DatasourceUID() string {
return "fake-ml-datasource"
}
func (f *FakeCommand) Execute(from, to time.Time, executor func(method string, path string, payload []byte) (response.Response, error)) (*backend.QueryDataResponse, error) {
r, err := executor(f.Method, f.Path, f.Payload)
f.Recordings = append(f.Recordings, struct {
From time.Time
To time.Time
Response response.Response
Error error
}{From: from, To: to, Response: r, Error: err})
if err != nil {
return nil, err
}
return f.Response, f.Error
}
func (f *FakeCommand) Type() string {
return "fake"
}