mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Don't pass datasource to newPostgresMacroEngine
This commit is contained in:
parent
3552a4cb86
commit
3955133f7e
@ -7,7 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/models"
|
|
||||||
"github.com/grafana/grafana/pkg/tsdb"
|
"github.com/grafana/grafana/pkg/tsdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,10 +20,8 @@ type postgresMacroEngine struct {
|
|||||||
timescaledb bool
|
timescaledb bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPostgresMacroEngine(datasource *models.DataSource) tsdb.SqlMacroEngine {
|
func newPostgresMacroEngine(timescaledb bool) tsdb.SqlMacroEngine {
|
||||||
engine := &postgresMacroEngine{}
|
return &postgresMacroEngine{timescaledb: timescaledb}
|
||||||
engine.timescaledb = datasource.JsonData.Get("timescaledb").MustBool(false)
|
|
||||||
return engine
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *postgresMacroEngine) Interpolate(query *tsdb.Query, timeRange *tsdb.TimeRange, sql string) (string, error) {
|
func (m *postgresMacroEngine) Interpolate(query *tsdb.Query, timeRange *tsdb.TimeRange, sql string) (string, error) {
|
||||||
|
@ -6,19 +6,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
||||||
"github.com/grafana/grafana/pkg/models"
|
|
||||||
"github.com/grafana/grafana/pkg/tsdb"
|
"github.com/grafana/grafana/pkg/tsdb"
|
||||||
. "github.com/smartystreets/goconvey/convey"
|
. "github.com/smartystreets/goconvey/convey"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMacroEngine(t *testing.T) {
|
func TestMacroEngine(t *testing.T) {
|
||||||
Convey("MacroEngine", t, func() {
|
Convey("MacroEngine", t, func() {
|
||||||
datasource := &models.DataSource{JsonData: simplejson.New()}
|
engine := newPostgresMacroEngine(false)
|
||||||
engine := newPostgresMacroEngine(datasource)
|
engineTS := newPostgresMacroEngine(true)
|
||||||
datasourceTS := &models.DataSource{JsonData: simplejson.New()}
|
|
||||||
datasourceTS.JsonData.Set("timescaledb", true)
|
|
||||||
engineTS := newPostgresMacroEngine(datasourceTS)
|
|
||||||
query := &tsdb.Query{}
|
query := &tsdb.Query{}
|
||||||
|
|
||||||
Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() {
|
Convey("Given a time range between 2018-04-12 00:00 and 2018-04-12 00:05", func() {
|
||||||
|
@ -32,7 +32,9 @@ func newPostgresQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndp
|
|||||||
log: logger,
|
log: logger,
|
||||||
}
|
}
|
||||||
|
|
||||||
return tsdb.NewSqlQueryEndpoint(&config, &rowTransformer, newPostgresMacroEngine(datasource), logger)
|
timescaledb := datasource.JsonData.Get("timescaledb").MustBool(false)
|
||||||
|
|
||||||
|
return tsdb.NewSqlQueryEndpoint(&config, &rowTransformer, newPostgresMacroEngine(timescaledb), logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateConnectionString(datasource *models.DataSource) string {
|
func generateConnectionString(datasource *models.DataSource) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user