Files
grafana/pkg/services/ngalert/writer/fake.go
Steve Simpson cc80681beb Alerting: Extend recording rules test to exercise writing with data sources. (#101775)
The change to use WriteDatasource was done in a previous commit, this adds a
test case using DatasourceWriter, in addition to the one using PrometheusWriter.
2025-03-07 13:51:50 +01:00

26 lines
619 B
Go

package writer
import (
"context"
"errors"
"time"
"github.com/grafana/grafana-plugin-sdk-go/data"
)
type FakeWriter struct {
WriteFunc func(ctx context.Context, name string, t time.Time, frames data.Frames, orgID int64, extraLabels map[string]string) error
}
func (w FakeWriter) WriteDatasource(ctx context.Context, dsUID string, name string, t time.Time, frames data.Frames, orgID int64, extraLabels map[string]string) error {
if w.WriteFunc == nil {
return nil
}
if dsUID != "" {
return errors.New("expected empty data source uid")
}
return w.WriteFunc(ctx, name, t, frames, orgID, extraLabels)
}