mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Fix InfluxDB tag variables parsing (#46862)
* regex bug fixed * remove unnecessary test
This commit is contained in:
parent
c5f295b5b3
commit
a9b55f7905
@ -16,7 +16,7 @@ import (
|
|||||||
type ResponseParser struct{}
|
type ResponseParser struct{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$(\s*([\@\w-]+?))*`)
|
legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$([\@\w-]+?)*`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rp *ResponseParser) Parse(buf io.ReadCloser, queries []Query) *backend.QueryDataResponse {
|
func (rp *ResponseParser) Parse(buf io.ReadCloser, queries []Query) *backend.QueryDataResponse {
|
||||||
|
@ -492,6 +492,16 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
|||||||
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = &Query{Alias: "alias $0, $1 - $2 - $3, $4: something"}
|
||||||
|
result = parser.Parse(prepare(response), addQueryToQueries(*query))
|
||||||
|
frame = result.Responses["A"]
|
||||||
|
name = "alias cpu, upc - $2 - $3, $4: something"
|
||||||
|
testFrame.Name = name
|
||||||
|
testFrame.Fields[1].Config.DisplayNameFromDS = name
|
||||||
|
if diff := cmp.Diff(testFrame, frame.Frames[0], data.FrameTestCompareOptions()...); diff != "" {
|
||||||
|
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||||
|
}
|
||||||
|
|
||||||
query = &Query{Alias: "alias $1"}
|
query = &Query{Alias: "alias $1"}
|
||||||
result = parser.Parse(prepare(response), addQueryToQueries(*query))
|
result = parser.Parse(prepare(response), addQueryToQueries(*query))
|
||||||
frame = result.Responses["A"]
|
frame = result.Responses["A"]
|
||||||
|
Loading…
Reference in New Issue
Block a user