2024-05-12 14:33:29 +00:00
|
|
|
package logstorage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPipeFieldsUpdateNeededFields(t *testing.T) {
|
|
|
|
f := func(s, neededFields, unneededFields, neededFieldsExpected, unneededFieldsExpected string) {
|
|
|
|
t.Helper()
|
2024-05-20 02:08:30 +00:00
|
|
|
expectPipeNeededFields(t, s, neededFields, unneededFields, neededFieldsExpected, unneededFieldsExpected)
|
2024-05-12 14:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// all the needed fields
|
|
|
|
f("fields s1, s2", "*", "", "s1,s2", "")
|
|
|
|
f("fields *", "*", "", "*", "")
|
|
|
|
|
|
|
|
// all the needed fields, unneeded fields do not intersect with src
|
|
|
|
f("fields s1, s2", "*", "f1,f2", "s1,s2", "")
|
|
|
|
f("fields *", "*", "f1,f2", "*", "f1,f2")
|
|
|
|
|
|
|
|
// all the needed fields, unneeded fields intersect with src
|
|
|
|
f("fields s1, s2", "*", "s1,f1,f2", "s2", "")
|
|
|
|
f("fields *", "*", "s1,f1,f2", "*", "s1,f1,f2")
|
|
|
|
|
|
|
|
// needed fields do not intersect with src
|
|
|
|
f("fields s1, s2", "f1,f2", "", "", "")
|
|
|
|
|
|
|
|
// needed fields intersect with src
|
|
|
|
f("fields s1, s2", "s1,f1,f2", "", "s1", "")
|
|
|
|
f("fields *", "s1,f1,f2", "", "s1,f1,f2", "")
|
|
|
|
}
|