8
8
"github.com/influxdata/telegraf"
9
9
tgConfig "github.com/influxdata/telegraf/config"
10
10
"github.com/influxdata/telegraf/plugins/inputs"
11
+ "github.com/influxdata/telegraf/plugins/processors"
11
12
"github.com/stretchr/testify/require"
12
13
)
13
14
@@ -55,6 +56,19 @@ func TestLoadingSpecialTypes(t *testing.T) {
55
56
require .EqualValues (t , 3 * 1000 * 1000 , inp .Size )
56
57
}
57
58
59
+ func TestLoadingProcessorWithConfig (t * testing.T ) {
60
+ proc := & testConfigProcessor {}
61
+ processors .Add ("test_config_load" , func () telegraf.Processor {
62
+ return proc
63
+ })
64
+
65
+ c := "./testdata/processor.conf"
66
+ _ , err := LoadConfig (& c )
67
+ require .NoError (t , err )
68
+
69
+ require .EqualValues (t , "yep" , proc .Loaded )
70
+ }
71
+
58
72
type testDurationInput struct {
59
73
Duration tgConfig.Duration `toml:"duration"`
60
74
Size tgConfig.Size `toml:"size"`
@@ -70,3 +84,18 @@ func (i *testDurationInput) Description() string {
70
84
func (i * testDurationInput ) Gather (acc telegraf.Accumulator ) error {
71
85
return nil
72
86
}
87
+
88
+ type testConfigProcessor struct {
89
+ Loaded string `toml:"loaded"`
90
+ }
91
+
92
+ func (p * testConfigProcessor ) SampleConfig () string {
93
+ return ""
94
+ }
95
+
96
+ func (p * testConfigProcessor ) Description () string {
97
+ return ""
98
+ }
99
+ func (p * testConfigProcessor ) Apply (metrics ... telegraf.Metric ) []telegraf.Metric {
100
+ return metrics
101
+ }
0 commit comments