mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
ae0a11d7c1
commit
f4ac7c50b6
2 changed files with 31 additions and 1 deletions
|
@ -246,7 +246,7 @@ func expectParsePipeFailure(t *testing.T, pipeStr string) {
|
||||||
|
|
||||||
lex := newLexer(pipeStr)
|
lex := newLexer(pipeStr)
|
||||||
p, err := parsePipe(lex)
|
p, err := parsePipe(lex)
|
||||||
if err == nil {
|
if err == nil && lex.isEnd() {
|
||||||
t.Fatalf("expecting error when parsing [%s]; parsed result: [%s]", pipeStr, p)
|
t.Fatalf("expecting error when parsing [%s]; parsed result: [%s]", pipeStr, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,9 @@ func expectParsePipeSuccess(t *testing.T, pipeStr string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("cannot parse [%s]: %s", pipeStr, err)
|
t.Fatalf("cannot parse [%s]: %s", pipeStr, err)
|
||||||
}
|
}
|
||||||
|
if !lex.isEnd() {
|
||||||
|
t.Fatalf("unexpected tail after parsing [%s]: [%s]", pipeStr, lex.s)
|
||||||
|
}
|
||||||
|
|
||||||
pipeStrResult := p.String()
|
pipeStrResult := p.String()
|
||||||
if pipeStrResult != pipeStr {
|
if pipeStrResult != pipeStr {
|
||||||
|
|
|
@ -8,6 +8,33 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestParsePipeUnpackJSONSuccess(t *testing.T) {
|
||||||
|
f := func(pipeStr string) {
|
||||||
|
t.Helper()
|
||||||
|
expectParsePipeSuccess(t, pipeStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
f(`unpack_json`)
|
||||||
|
f(`unpack_json from x`)
|
||||||
|
f(`unpack_json from x result_prefix abc`)
|
||||||
|
f(`unpack_json result_prefix abc`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParsePipeUnpackJSONFailure(t *testing.T) {
|
||||||
|
f := func(pipeStr string) {
|
||||||
|
t.Helper()
|
||||||
|
expectParsePipeFailure(t, pipeStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
f(`unpack_json foo`)
|
||||||
|
f(`unpack_json from`)
|
||||||
|
f(`unpack_json from x y`)
|
||||||
|
f(`unpack_json from x result_prefix`)
|
||||||
|
f(`unpack_json from x result_prefix a b`)
|
||||||
|
f(`unpack_json result_prefix`)
|
||||||
|
f(`unpack_json result_prefix a b`)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPipeUnpackJSON(t *testing.T) {
|
func TestPipeUnpackJSON(t *testing.T) {
|
||||||
f := func(pipeStr string, rows, rowsExpected [][]Field) {
|
f := func(pipeStr string, rows, rowsExpected [][]Field) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
Loading…
Reference in a new issue