mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 10:50:37 -06:00
78596a6756
Fixes #30144 Co-authored-by: dsotirakis <sotirakis.dim@gmail.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com> Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> Co-authored-by: Leon Sorokin <leeoniya@gmail.com> Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com> Co-authored-by: spinillos <selenepinillos@gmail.com> Co-authored-by: Karl Persson <kalle.persson@grafana.com> Co-authored-by: Leonard Gram <leo@xlson.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package testdatasource
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/grafana/grafana-plugin-sdk-go/experimental"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFlightPathScenario(t *testing.T) {
|
|
cfg := setting.NewCfg()
|
|
p := &TestDataPlugin{
|
|
cfg: cfg,
|
|
}
|
|
|
|
t.Run("simple flight", func(t *testing.T) {
|
|
start := time.Date(2020, time.January, 10, 23, 0, 0, 0, time.UTC)
|
|
qr := &backend.QueryDataRequest{
|
|
Queries: []backend.DataQuery{
|
|
{
|
|
RefID: "X",
|
|
TimeRange: backend.TimeRange{
|
|
From: start,
|
|
To: start.Add(time.Second * 10),
|
|
},
|
|
Interval: time.Second,
|
|
MaxDataPoints: 10,
|
|
JSON: json.RawMessage(`{}`), // always 10s?
|
|
},
|
|
},
|
|
}
|
|
|
|
rsp, err := p.handleFlightPathScenario(context.Background(), qr)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, rsp)
|
|
for k, v := range rsp.Responses {
|
|
dr := v
|
|
filePath := filepath.Join("testdata", fmt.Sprintf("flight-simple-%s.txt", k))
|
|
err = experimental.CheckGoldenDataResponse(filePath, &dr, true)
|
|
require.NoError(t, err)
|
|
}
|
|
})
|
|
}
|