mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-27 02:46:47 +01:00
bac193e50b
Some checks are pending
build / Build (push) Waiting to run
CodeQL Go / Analyze (push) Waiting to run
main / lint (push) Waiting to run
main / test (test-full) (push) Blocked by required conditions
main / test (test-full-386) (push) Blocked by required conditions
main / test (test-pure) (push) Blocked by required conditions
publish-docs / Build (push) Waiting to run
Empty fields are treated as non-existing fields by VictoriaLogs data model. So there is no sense in returning empty fields in query results, since they may mislead and confuse users.
31 lines
689 B
Go
31 lines
689 B
Go
package logstorage
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestLogfmtParser(t *testing.T) {
|
|
f := func(s, resultExpected string) {
|
|
t.Helper()
|
|
|
|
p := getLogfmtParser()
|
|
defer putLogfmtParser(p)
|
|
|
|
p.parse(s)
|
|
result := MarshalFieldsToLogfmt(nil, p.fields)
|
|
if string(result) != resultExpected {
|
|
t.Fatalf("unexpected result when parsing [%s]; got\n%s\nwant\n%s\n", s, result, resultExpected)
|
|
}
|
|
}
|
|
|
|
f(``, ``)
|
|
f(`foo=bar`, `foo=bar`)
|
|
f(`foo="bar=baz x=y"`, `foo="bar=baz x=y"`)
|
|
f(`foo=`, `foo=`)
|
|
f(`foo`, `foo=`)
|
|
f(`foo bar`, `foo= bar=`)
|
|
f(`foo bar=baz`, `foo= bar=baz`)
|
|
f(`foo=bar baz="x y" a=b`, `foo=bar baz="x y" a=b`)
|
|
f(` foo=bar baz=x =z qwe`, `foo=bar baz=x _msg=z qwe=`)
|
|
}
|