Add left function to string processor (#6189)
This commit is contained in:
committed by
Daniel Nelson
parent
28f1bdb696
commit
ef4f4eed3a
@@ -479,6 +479,38 @@ func TestFieldKeyConversions(t *testing.T) {
|
||||
require.Equal(t, "/mixed/CASE/paTH/?from=-1D&to=now", fv)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Should trim the existing field to 6 characters",
|
||||
plugin: &Strings{
|
||||
Left: []converter{
|
||||
{
|
||||
Field: "Request",
|
||||
Width: 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
check: func(t *testing.T, actual telegraf.Metric) {
|
||||
fv, ok := actual.GetField("Request")
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "/mixed", fv)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Should do nothing to the string",
|
||||
plugin: &Strings{
|
||||
Left: []converter{
|
||||
{
|
||||
Field: "Request",
|
||||
Width: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
check: func(t *testing.T, actual telegraf.Metric) {
|
||||
fv, ok := actual.GetField("Request")
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "/mixed/CASE/paTH/?from=-1D&to=now", fv)
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user